20tps
查看原帖
20tps
1058217
wangyuzhe11楼主2024/10/13 19:39
#include<bits/stdc++.h>
using namespace std;
#define db=double;
int t,n,m;
string s;
int main(){
	cin>>t;
	while(cin>>n>>m>>s){
		int a=0,b=0,x=0,y=0,f=0;
		for(int i=0;i<s.size()&&f!=1;i++){
			if(s[i]=='1'){
				x++;
				if(x>1){
					cout<<"No\n";
					f=1;
				}
				if(y!=a&&y!=b&&a!=0&&b!=0){
					cout<<"No\n";
					f=1;
				}
				if(a>=n||b>=n){
					cout<<"No\n";
					f=1;
				}
				if(a==0)a=y;
				if(b==0)b=y;
				y=0;
			}
			else{
				x=0;
				y++;
			}
		}
		if(f==0)cout<<"Yes\n";
	}
	return 0;
}
2024/10/13 19:39
加载中...