fork download
  1. test = int(input())
  2. for t in range(test):
  3. n , k = map(int,input().split())
  4. s = input()
  5. lastone = -1
  6. count = 0
  7.  
  8. for i in range(n):
  9. if int(s[i])==1:
  10. if lastone>=max(0,i-k) and lastone<=i-1:
  11. continue
  12.  
  13. else:
  14. count+=1
  15. lastone = i
  16. else:
  17. continue
  18. print(count)
  19.  
  20.  
  21.  
Success #stdin #stdout 0.08s 14124KB
stdin
9
2 2
11
6 6
100001
5 3
10000
7 2
1010101
7 4
0000001
3 3
010
3 2
011
7 4
1001001
8 3
00000000
stdout
1
1
1
2
1
1
1
2
0