1. 程式人生 > >ACM刷題之codeforces————Cinema

ACM刷題之codeforces————Cinema

Cinema time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

Rami and K of his friends are going to watch a movie tonight. There are only one row that contains some available seats, all other rows are taken. Given the description of this row, Rami wants to know if he can find consecutive seats available to sit with his friends.

Input

The first line of input contains a single integer T

, the number of test cases.

The first line of each test case consists of two-separated integers CK (1 ≤ C, K ≤ 105), the number of seats in the row and the number of friends going with Rami, respectively.

The second line contains a string of C digits, where 0 represents an empty seat, and 1 represents taken one.

Output

For each test case, print a single line with yes if Rami can find a place for him and his friends, otherwise print no.

Example input
2
5 2
10101
6 3
000011
output
no
yes

水題 不過記得算上自己 下面是ac程式碼
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<iostream>
using namespace std;
#define MID(x,y) ((x+y)>>1)
#define CLR(arr,val) memset(arr,val,sizeof(arr))
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int N=2e5+7;

char s[111111];

int main()
{
	//freopen("f:/input.txt", "r", stdin);
	int zu,i,j,k,n,m,cnt,f;
	int len1;
	scanf("%d",&zu);
	while(zu--)
	{
		scanf("%d%d",&n,&m);
		scanf("%s",s);

		//scanf("%s",s);
			
		f=0;
		for(i=0;i<n;)
		{
			j=i+1;
			cnt=0;
			if(s[i]=='0')
			{
				while(j<n&&s[j]=='0')
				{
					cnt++;
					//printf("%d\n",cnt);
					if(cnt>=m)
					{
						f=1;
						break;
					}
					++j;
				}
			}
			
			i=j;
		}
		
		if(f==1)
		{
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}
	
}