QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#449279#8467. Binary Strings275307894a#AC ✓76ms157412kbC++142.8kb2024-06-20 21:21:012024-06-20 21:21:01

Judging History

你现在查看的是最新测评结果

  • [2024-06-20 21:21:01]
  • 评测
  • 测评结果:AC
  • 用时:76ms
  • 内存:157412kb
  • [2024-06-20 21:21:01]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=1e6+5,M=N*4+5,K=1000+5,mod=1e9+7,Mod=mod-1;const db eps=1e-9;const int INF=2e9+7;mt19937 rnd(time(0));
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
int n,m,k;char s[N];
int merge(int x,int y){
	if(!x||!y) return x|y;
	if(x==y) return x;
	return -1;
}
namespace ACAM{
	int son[N][2],ZJAKIOI;
	int w[N],val[N];
	int cnt=1,fail[N];
	int flag[N];
	vector<int> S[N];
	int vis[N][3];
	void clr(){
		for(int i=1;i<=cnt;i++){
			w[i]=0;
			fail[i]=0;
			Me(son[i],0);
			flag[i]=0;
			S[i].clear();
			Me(vis[i],0);
			val[i]=0;
		}
		cnt=1;ZJAKIOI=0;
	}
	void insert(char *s,int op){
		int k=strlen(s+1);
		int x=1;
		for(int i=1;i<=k;i++){
			if(!son[x][s[i]-'0']) son[x][s[i]-'0']=++cnt;
			x=son[x][s[i]-'0'];
		}
		if(op) w[x]=merge(w[x],op);
		else flag[x]=1;
	}
	void push(int x,int La){
		for(int i:S[x]){
			w[i]=merge(w[i],w[x]);
			flag[i]|=flag[x];
			push(i,x);
		}
	}
	void dfs(int x,int ws){
		if(flag[x]||ZJAKIOI) return;
		val[x]=ws=merge(val[x],ws);
		int op=0;
		if(ws==-1) op=2;
		else if(ws>0)op=1;
		if(vis[x][op]) return;
		vis[x][op]=1;
		if(w[x]==-1) ZJAKIOI=1;
		if(w[x]&&ws&&w[x]^ws) ZJAKIOI=1;
		ws=merge(ws,w[x]);
		for(int i:son[x]) dfs(i,ws);
	}
	int build(){
		queue<int> q;
		for(int i=0;i<2;i++){
			if(son[1][i]) q.push(son[1][i]),fail[son[1][i]]=1;
			else son[1][i]=1;
		}
		while(!q.empty()){
			int x=q.front();q.pop();
			for(int i=0;i<2;i++){
				if(son[x][i]) fail[son[x][i]]=son[fail[x]][i],q.push(son[x][i]);
				else son[x][i]=son[fail[x]][i];
			}
		}
		for(int i=2;i<=cnt;i++) S[fail[i]].push_back(i);
		push(1,0);
		dfs(1,0);
		return ZJAKIOI;
	}
}
void Solve(){
	int i,j;scanf("%d%d",&n,&m);
	ACAM::clr();
	for(i=1;i<=n;i++){
		scanf("%s",s+1);
		ACAM::insert(s,i);
	}
	for(i=1;i<=m;i++){
		scanf("%s",s+1);
		ACAM::insert(s,0);
	}
	puts(ACAM::build()?"Yes":"No");
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

详细

Test #1:

score: 100
Accepted
time: 5ms
memory: 40732kb

input:

2
3 2
100
001
010
1001
000
2 4
100
001
010
1001
000
11

output:

Yes
No

result:

ok 2 token(s): yes count is 1, no count is 1

Test #2:

score: 0
Accepted
time: 3ms
memory: 40812kb

input:

2
2 4
01
10
00
11
0101
1010
2 2
0
1
01
10

output:

Yes
No

result:

ok 2 token(s): yes count is 1, no count is 1

Test #3:

score: 0
Accepted
time: 22ms
memory: 40764kb

input:

25000
2 1
01
01111
10
2 2
111
01
000
10
2 2
0
1111
10
11111
2 1
110
1
11
2 2
11
01
1101
0
2 2
01110
00101
111
1010
2 1
11010
10110
11
2 1
10101
0
001
2 2
01111
10010
000
10
2 2
10110
0
00
01110
2 2
10011
000
011
01
2 1
00
01110
100
2 2
0
0010
1000
1
2 1
0
00
1
2 2
0010
10111
10011
010
2 1
1000
0100
...

output:

Yes
Yes
Yes
No
No
No
No
Yes
No
Yes
No
Yes
No
Yes
No
No
No
No
No
Yes
No
No
Yes
No
No
No
No
No
No
No
Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
No
Yes
Yes
No
No
Yes
Yes
Yes
No
No
Yes
Yes
Yes
Yes
No
Yes
Yes
No
Yes
No
Yes
No
No
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
No
No
No
Yes
No
N...

result:

ok 25000 token(s): yes count is 12530, no count is 12470

Test #4:

score: 0
Accepted
time: 23ms
memory: 36592kb

input:

25000
2 1
001110
110
0011
2 1
01010
0
110
2 2
110101
10
11101
1000
2 1
010
01
101011
2 2
01110
1011
1001
11101
2 1
011
100111
110
2 1
00
1010
001010
2 2
001000
0110
10
010
2 2
101010
001010
000
0
2 2
010
1
10
10000
2 1
01
1
11
2 1
010
00111
111111
2 2
100011
11001
010
000001
2 1
0
0
1
2 2
11111
0101...

output:

No
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
Yes
Yes
Yes
Yes
No
Yes
No
No
Yes
No
No
No
No
No
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
No
Yes
No
No
No
Yes
No
No
No
Yes
Yes
No
No
No
No
Yes
Yes
Yes
No
Yes
No
No
No
No
No
No
Yes
No
Yes
Yes
Yes
Yes
No
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
No
No
Yes
Yes
No
Yes
Yes
...

result:

ok 25000 token(s): yes count is 13205, no count is 11795

Test #5:

score: 0
Accepted
time: 22ms
memory: 40856kb

input:

25000
2 2
00011
0000
111111
0
2 2
01101
0011011
101001
11
2 2
011
011
1
01100
2 2
10101
11111
01
010111
2 1
101010
01
11
2 1
00111
11001
00001
2 1
011
000110
1
2 1
01
0110111
1101011
2 2
0001001
10
011011
111001
2 2
11100
111
11001
101
2 2
1000
110110
000100
0111
2 1
000
011
111100
2 1
11110
00
1101...

output:

No
No
No
No
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
No
Yes
Yes
No
No
Yes
No
Yes
Yes
Yes
Yes
No
Yes
Yes
No
No
Yes
No
Yes
Yes
No
Yes
Yes
Yes
Yes
No
No
No
No
Yes
No
Yes
Yes
Yes
No
No
No
Yes
No
Yes
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
Yes
No
No
Yes
Yes
Yes
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
...

result:

ok 25000 token(s): yes count is 13782, no count is 11218

Test #6:

score: 0
Accepted
time: 27ms
memory: 36696kb

input:

25000
2 2
1000110
00000
011
01
2 2
0001100
00
001
0111
2 1
0000
10
000110
2 2
001110
1110100
01011001
1100
2 2
00101110
111110
11101
0
2 1
01
1100
110101
2 2
01010001
0001111
00
10000
2 2
001100
10
0111
001011
2 1
01010
1001101
10111
2 2
101
011110
10001
010
2 2
1111011
00
11111110
010
2 2
01
100011...

output:

No
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
No
No
Yes
Yes
Yes
No
No
No
No
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
No
No
No
Yes
No
No
No
No
No
Yes
Yes
No
No
Yes
Yes
No
No
No
No
Yes
No
No
No
No
No
Yes
Yes
Yes
Yes
No
No
No
Yes
Yes
Yes
Yes
No
Yes...

result:

ok 25000 token(s): yes count is 14308, no count is 10692

Test #7:

score: 0
Accepted
time: 29ms
memory: 40792kb

input:

25000
2 1
1111111
0011
00
2 1
110
1111
01101
2 1
000
010
00010
2 1
11
1110
10
2 2
001100100
11111010
00001
1101101
2 1
011
000000
011110
2 2
0
1110101
1
00000111
2 2
011100100
1
0010111
000000
2 1
110011111
1
101010010
2 1
01
011011
01010011
2 1
0001001
1110
01100111
2 1
001110100
00
101101101
2 2
0...

output:

No
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
No
Yes
Yes
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
Yes
No
No
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
No
Yes
No
No
No
Yes
No
No
No
Yes
No
No
Yes
Yes
Yes
N...

result:

ok 25000 token(s): yes count is 14837, no count is 10163

Test #8:

score: 0
Accepted
time: 34ms
memory: 36872kb

input:

25000
2 1
001011
0
0
2 2
000110
11100100
111
11011111
2 1
1001011110
110011
1100
2 2
11100010
1100100110
111010010
0
2 2
10
1
100110101
1
2 1
001
1110
11
2 2
1
100101111
00101100
1
2 1
010110
1101001
1101
2 1
011001011
000001
10
2 1
0111
10101
01101
2 1
111101
001
0
2 1
01
0
11
2 1
001101101
0011000...

output:

No
No
No
No
No
No
No
No
No
Yes
No
Yes
Yes
Yes
Yes
Yes
No
No
No
Yes
Yes
Yes
No
No
Yes
Yes
No
Yes
Yes
Yes
No
No
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
No
No
Yes
No
Yes
Yes
Yes
Yes
No
No
No
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Ye...

result:

ok 25000 token(s): yes count is 15356, no count is 9644

Test #9:

score: 0
Accepted
time: 18ms
memory: 40768kb

input:

16666
2 1
00010
10
00
2 1
1
00001
1
2 1
11000
00000
00000
2 1
10101
000
1100
2 2
0
01101
01011
00
2 2
0011
10
1
100
3 1
100
0
011
011
3 1
0
01
011
1
3 1
1
11
10010
00
3 2
1111
1
11
0111
0
2 1
0
001
0111
3 3
10
001
01
000
11
01001
2 1
00011
00101
0000
2 2
1
000
11
0110
2 2
01010
00
1
0
3 3
01
10011
1...

output:

No
No
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
No
Yes
Yes
No
Yes
No
No
No
No
Yes
Yes
No
Yes
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
No
Yes
No
No
No
No
No
Yes
No
No
No
Yes
No
Yes
Yes
No
No
Yes
Yes
No
No
No
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
No
Yes
No
No
Y...

result:

ok 16666 token(s): yes count is 8153, no count is 8513

Test #10:

score: 0
Accepted
time: 19ms
memory: 36648kb

input:

16666
2 2
00
000011
11011
0100
3 3
101110
00
110
1
101
01
2 2
000110
01
11
011
2 2
000110
1
10001
0
2 3
01
101100
11
111011
010
3 2
011001
01
011
1
110100
3 2
111000
01111
10
01
100100
3 3
0011
00
101
00000
01000
00
2 3
01000
111011
110
011
01101
3 3
01111
0
10000
100101
110
011
2 2
01101
1100
1000
...

output:

Yes
No
No
No
No
No
Yes
No
No
Yes
No
No
No
No
No
Yes
No
No
No
No
No
No
Yes
Yes
Yes
No
No
Yes
No
No
No
No
Yes
No
No
Yes
Yes
No
No
No
Yes
No
Yes
Yes
No
No
Yes
Yes
No
Yes
Yes
No
No
Yes
Yes
Yes
Yes
No
Yes
No
No
Yes
Yes
Yes
No
No
Yes
No
Yes
No
Yes
No
Yes
No
No
Yes
No
Yes
No
No
No
No
No
No
No
No
Yes
Yes
Ye...

result:

ok 16666 token(s): yes count is 8546, no count is 8120

Test #11:

score: 0
Accepted
time: 16ms
memory: 36640kb

input:

16666
2 1
00010
0110101
1111110
2 1
1101101
01001
1011
3 1
001010
110100
0110000
111000
2 1
110011
000111
10101
3 3
1001000
1
11
1011000
0
001
2 3
110
00101
1101110
0101
01
3 1
1110010
100011
10
0
3 1
0111000
111001
000110
011110
2 1
10011
1
1000111
3 2
011
1100110
01
00011
110001
2 1
111
1101
0010
...

output:

Yes
No
Yes
Yes
Yes
No
No
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
No
No
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
Yes
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
No
No
No
No
Yes
Yes
Yes
No
Yes
No
Yes
Yes
No
No
Yes
No
No
No
No
No
No
No
No
Yes
No
Yes
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No...

result:

ok 16666 token(s): yes count is 8970, no count is 7696

Test #12:

score: 0
Accepted
time: 14ms
memory: 36696kb

input:

16666
2 2
1101010
10010011
0
0111
3 2
011110
1
1001
10
11011
2 1
1001001
110
10
3 1
100
0
1011111
0000010
3 1
10011111
00
1100
1011101
3 1
000
10011
000101
110
3 1
1101
0101111
11110
1111
2 3
000100
0100
0001101
0100101
01110110
2 3
01100
1
1010
10
1
2 1
1100101
1
111
3 2
00
1
000011
0
1010
3 3
10
0...

output:

No
No
No
Yes
Yes
Yes
No
Yes
No
Yes
No
Yes
No
No
Yes
Yes
Yes
Yes
Yes
No
No
Yes
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
Yes
Yes
No
Yes
No
Yes
Yes
No
Yes
Yes
No
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
No
Yes
No
No
Yes
No
Yes
Yes
Yes
No
Yes
No
Yes
No
No
No
No
No
Yes
Yes
Yes
Yes
No...

result:

ok 16666 token(s): yes count is 9238, no count is 7428

Test #13:

score: 0
Accepted
time: 23ms
memory: 36868kb

input:

16666
2 3
111
0
00011
0
0111100
2 1
100100100
1101
00
3 2
1001011
01010110
01
101111010
01001
3 2
0
110101
0000110
00010010
11110
2 3
11100001
1
110
00101111
00
3 1
10000
0110
101
11
3 2
000
1111
00101111
11101111
1111110
2 3
011101111
101000
0
0
001111101
2 3
010
00
01011
10100101
0
2 1
10
10
11100...

output:

No
No
Yes
Yes
No
Yes
Yes
No
No
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
No
Yes
No
No
Yes
No
No
No
Yes
No
No
No
No
Yes
No
Yes
No
Yes
No
No
No
Yes
No
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
No
Yes
No
No
Yes
No
No
Yes
No
No
No
No
No
Yes
No
Yes
No
No
No
Yes
No
No
Yes
No...

result:

ok 16666 token(s): yes count is 9511, no count is 7155

Test #14:

score: 0
Accepted
time: 21ms
memory: 40732kb

input:

16666
2 1
0111
0100
00
2 3
1011011101
100110011
000
100010101
11111010
3 1
101010101
011001
1101000
01000
3 2
1
11010110
10111111
1
110
3 1
101
001000
111101
01011
2 2
00000
111000
1
00010110
3 2
011
00101100
00
101011001
0010001111
2 1
1010101
00
110111
2 2
111000
0
01010
01010
2 3
01101
110101
0
1...

output:

No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
No
No
Yes
Yes
Yes
Yes
Yes
No
No
No
No
No
No
No
Yes
No
No
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
No
Yes
Yes
Yes
Yes
No
Yes
Yes
No
Yes
Yes
No
Yes
Yes
No
No
No
Yes
No
Yes
No
Yes
No
No
No
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
No
No
No
No
Yes
Yes
Yes
No
No
No
Yes
No
No
No
...

result:

ok 16666 token(s): yes count is 9770, no count is 6896

Test #15:

score: 0
Accepted
time: 12ms
memory: 36824kb

input:

12500
2 2
00011
1100
111
10
4 1
0
01110
1
11001
01100
2 1
01
01011
0000
4 1
0
101
110
01
1
4 3
1011
00
0
101
11100
00
1
3 2
1100
10001
00110
1111
11
3 3
110
01
00111
01001
11
10
2 3
00100
10100
10111
01
0
4 2
1011
1
1110
00
101
11000
2 4
00101
1100
11100
00
0111
0
3 2
0111
111
00010
01111
10110
3 4
...

output:

No
Yes
Yes
No
No
No
No
No
Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
No
Yes
No
Yes
No
Yes
Yes
No
Yes
Yes
No
No
No
No
No
No
No
Yes
Yes
Yes
No
No
Yes
Yes
Yes
No
No
Yes
Yes
No
Yes
Yes
No
Yes
Yes
No
Yes
Yes
No
Yes
No
No
Yes
No
No
Yes
No
No
No
No
No
No
Yes
No
Yes
Yes
No
Yes
No
No
No
Yes
Yes
Yes
No
Yes
Yes
No
No
No...

result:

ok 12500 token(s): yes count is 5851, no count is 6649

Test #16:

score: 0
Accepted
time: 16ms
memory: 36672kb

input:

12500
3 2
001110
00010
0
11
11100
2 3
01
00
00
10001
0000
4 1
01110
1101
1000
11100
000101
3 2
1
0
000
11110
00
4 1
00000
01
01
00
1011
4 1
1
1110
111110
110101
110101
2 2
00011
1
0
10
2 2
0
10000
010
10100
4 1
000
1011
10100
00
01
4 3
1
110110
001110
100010
111111
1001
101
3 1
0111
001000
010
11001...

output:

Yes
No
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
Yes
No
No
Yes
No
Yes
No
Yes
No
No
Yes
No
No
Yes
No
No
No
No
No
No
Yes
No
No
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
No
No
Yes
No
Yes
No
Yes
No
Yes
No
Yes
No
No
Yes
Yes
No
Yes
No
No
No
No
Yes
No
Yes
Yes
Yes
Yes
No
No
Yes
Yes
Yes
No
Yes
Yes
No
Yes
...

result:

ok 12500 token(s): yes count is 6171, no count is 6329

Test #17:

score: 0
Accepted
time: 13ms
memory: 40952kb

input:

12500
2 3
1100110
101110
10110
1001001
100
4 3
11
0010100
10000
0000000
0101101
000
0110
4 1
1001
11
1100
101001
1
4 1
010110
1010
11
0011
100111
2 4
000001
0
01
01
0
010011
3 4
101
1
100110
0
00
0100100
1101001
2 4
000
00
00111
111
010011
11
4 3
0
1001
0110011
0111
1
00
011011
2 3
1
1001010
11
1001...

output:

No
Yes
No
Yes
No
No
Yes
No
No
No
Yes
Yes
No
Yes
No
No
No
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
No
No
No
Yes
No
Yes
Yes
Yes
No
Yes
No
Yes
No
Yes
Yes
No
No
No
No
Yes
Yes
No
Yes
Yes
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
Yes
Yes
No
No
No
Yes
No
Yes
Yes
No
Yes
No
No
No
Yes
Yes
No
Yes
No
...

result:

ok 12500 token(s): yes count is 6366, no count is 6134

Test #18:

score: 0
Accepted
time: 20ms
memory: 40728kb

input:

12500
3 3
1101110
11
01111
1110001
0
1
3 1
11110
01101
1010
01
4 2
11111000
1
111
1111
10
001001
4 3
1000110
00010
000
1000101
00010
01
1
4 4
00101100
0011
01
11110110
01
111111
010
101
4 4
011010
110000
001011
00100
1101
0000000
1
010100
3 1
00001101
11101100
1000
01011
3 1
001
101110
1101
1111111
...

output:

No
No
Yes
No
No
No
Yes
Yes
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
No
No
Yes
No
Yes
Yes
Yes
Yes
No
No
No
Yes
No
No
No
Yes
Yes
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
No
Yes
No
No
No
Yes
Yes
No
Yes
Yes
No
No
Yes
Yes
Yes
No
Yes
Yes
No
Yes...

result:

ok 12500 token(s): yes count is 6740, no count is 5760

Test #19:

score: 0
Accepted
time: 21ms
memory: 38836kb

input:

12500
3 3
1011
001111101
11011
1101011
1101100
0100
4 4
01
100
1110111
11101
1101
101010011
001
0
4 2
000
0010
1001
0
111
10001101
4 4
11110
1001
100110010
0110001
010
1
011
110
4 4
001011111
1111011
0
0111110
0110
10100
10101000
1000
2 2
1010
01100100
0
0011010
3 3
0
001
010
0111
0011
0111
2 2
0011...

output:

Yes
No
Yes
No
Yes
No
Yes
No
No
Yes
Yes
Yes
No
No
Yes
No
No
Yes
No
No
Yes
Yes
Yes
Yes
Yes
No
Yes
No
No
Yes
No
Yes
No
No
No
No
No
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
No
No
No
No
No
Yes
No
Yes
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
No
No
No
Yes
Yes
No
Yes
Yes
No
No
Yes
Yes
No
No
Yes
No
Yes
Yes
...

result:

ok 12500 token(s): yes count is 6794, no count is 5706

Test #20:

score: 0
Accepted
time: 17ms
memory: 36640kb

input:

12500
2 3
11100010
10
1100
1010110
0
4 3
011
11001
011010011
1100100011
01011
000011111
1000
4 4
1011001011
1101001101
0100101
1101100
10111100
0
110101110
11111
4 2
001
1111
1000101
010
00011
0010100111
3 4
00001
010
100
00010101
0010000
111000
11010111
4 2
0
011101010
10011101
101001010
101010101
...

output:

No
Yes
No
Yes
Yes
Yes
No
No
No
No
Yes
Yes
Yes
Yes
No
No
Yes
Yes
No
No
No
Yes
No
No
Yes
Yes
No
No
Yes
Yes
No
No
Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
Yes
Yes
Yes
No
No
No
Yes
Yes
Yes
No
Yes
No
No
Yes
Yes
Yes
No
Yes
No
No
Yes
Yes
No
Yes
Yes
No
Yes
No
No
No
No
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
No
No
Yes
Yes
Ye...

result:

ok 12500 token(s): yes count is 7037, no count is 5463

Test #21:

score: 0
Accepted
time: 15ms
memory: 36760kb

input:

10000
4 4
00
00
1110
010
1
1
1
1
4 4
0011
101
01011
1011
11111
001
0
0011
2 4
01001
111
00010
00
011
0011
5 2
0011
110
0
010
1101
111
0010
2 5
111
00111
111
0001
1
0
1
2 5
0001
1
11
000
10
010
0000
2 2
11111
1
101
0
3 2
0
11100
11
1
01110
4 1
1
1
010
01100
111
3 1
01000
001
11111
1111
2 1
010
0
10
2...

output:

Yes
No
No
Yes
No
No
Yes
No
Yes
Yes
No
Yes
Yes
Yes
No
Yes
Yes
No
Yes
Yes
No
No
No
No
Yes
Yes
Yes
Yes
No
Yes
Yes
No
Yes
Yes
No
Yes
No
Yes
No
No
No
No
No
Yes
No
Yes
Yes
No
No
No
Yes
No
Yes
Yes
No
No
Yes
No
Yes
No
No
Yes
Yes
Yes
Yes
No
No
No
No
Yes
No
Yes
No
No
Yes
No
No
No
Yes
No
No
No
No
Yes
No
No
No
...

result:

ok 10000 token(s): yes count is 4533, no count is 5467

Test #22:

score: 0
Accepted
time: 17ms
memory: 38764kb

input:

10000
4 5
01
1011
000100
11010
0
00
0
01
11
5 1
01111
01111
0
1
111
111001
4 3
001
011101
000001
001101
0
011
0
2 2
0
1
0110
1000
4 4
111
000
10110
11010
01011
100100
10000
000010
4 4
1011
0
0
0
100110
001010
100
11110
2 1
001001
00
00100
5 3
000100
011
111101
0
0101
001000
1
110
5 5
11
010111
10
00...

output:

No
Yes
No
Yes
Yes
Yes
No
No
No
No
Yes
No
No
No
No
No
Yes
No
Yes
Yes
No
Yes
Yes
No
No
No
No
No
No
Yes
Yes
No
No
No
No
No
Yes
No
Yes
Yes
Yes
Yes
No
No
Yes
Yes
No
Yes
Yes
Yes
No
No
Yes
No
No
No
Yes
No
No
Yes
No
Yes
No
No
Yes
No
No
Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
No
No
No
Yes
No
Yes
Yes
Yes
No
Yes
No
...

result:

ok 10000 token(s): yes count is 4793, no count is 5207

Test #23:

score: 0
Accepted
time: 12ms
memory: 36876kb

input:

10000
4 4
1
0101
001
00111
01
111
1011010
10
3 2
00001
01100
1
010
01001
2 3
0010001
0110
01000
100
10
5 4
1
0100111
1101
0
01000
011000
00
00
01000
4 3
1111011
10
01011
0010
010011
10
1011
3 2
110
10
1
00101
0
2 4
11100
1010
011000
1
011110
0
3 2
1
011100
111110
00
11
5 4
101100
11011
100
0101001
0...

output:

No
Yes
No
Yes
No
No
No
No
No
No
Yes
No
Yes
Yes
No
No
Yes
No
Yes
Yes
No
Yes
No
Yes
No
Yes
Yes
Yes
No
No
Yes
Yes
No
Yes
No
Yes
No
Yes
No
Yes
Yes
Yes
No
Yes
Yes
No
No
No
Yes
No
Yes
No
Yes
No
Yes
Yes
No
No
No
No
Yes
Yes
No
Yes
Yes
Yes
No
No
Yes
No
No
Yes
Yes
No
No
Yes
No
Yes
Yes
Yes
No
Yes
No
No
No
Yes
...

result:

ok 10000 token(s): yes count is 4940, no count is 5060

Test #24:

score: 0
Accepted
time: 18ms
memory: 40864kb

input:

10000
4 2
1000000
01011
11
111001
0111100
10010
5 4
001011
000000
11100000
100010
101
110111
1111000
1
0
4 5
0001001
100111
10
10
01
10010
01011
011000
11001
3 1
010
01001001
1010
0
3 5
010
11
100
10101
0001
1
00
1111001
5 2
01100000
11000101
11
1101000
101
011111
001000
2 3
1011
00100001
1100
00000...

output:

Yes
No
Yes
No
No
Yes
Yes
Yes
No
Yes
No
No
Yes
Yes
No
Yes
Yes
No
Yes
Yes
No
Yes
No
Yes
Yes
No
No
No
Yes
No
No
No
No
No
Yes
Yes
No
No
No
Yes
Yes
No
No
Yes
No
Yes
Yes
No
Yes
Yes
Yes
No
Yes
No
No
Yes
No
No
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
Yes
No
No
Yes
Yes
No
No
N...

result:

ok 10000 token(s): yes count is 5114, no count is 4886

Test #25:

score: 0
Accepted
time: 19ms
memory: 36868kb

input:

10000
4 2
101100001
10001101
00111
1
111011011
01010
3 1
1100000
00
0110
10
2 1
0
0101
100
4 2
11011
01
001
00100111
01111000
100110
2 4
100100100
110011
100
11100101
1101000
0
3 2
00111101
11
1
10010
101111
5 2
01100001
011
0111
011100000
1000
0001100
000
2 3
0100100
00010000
101001110
001000
1
5 1...

output:

Yes
No
Yes
Yes
No
Yes
Yes
No
Yes
Yes
No
No
Yes
Yes
Yes
Yes
Yes
No
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
No
No
No
No
No
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
No
No
Yes
Yes
Yes
No
No
Yes
Yes
No
Yes
Yes
No
Yes
No
No
Yes
Yes
Yes
No
Yes
Yes
Yes
No
No
Yes
Yes
No
Yes
No
Yes
Yes
No
No
No
No
Yes
Yes
Y...

result:

ok 10000 token(s): yes count is 5291, no count is 4709

Test #26:

score: 0
Accepted
time: 20ms
memory: 40916kb

input:

10000
4 1
101011
1011111
001100101
110
11011100
4 3
1
0
1
011
00
00001
1110111001
2 5
001000
00001
0010011
000010101
01101
1100010
00001
5 1
11
010010
00
0000110
01100000
0001111
4 1
01
000100110
000110
01110111
11111
4 3
0111010010
10
0001100
0111
1
0110001111
110010
3 1
010
0000000100
11111000
000...

output:

Yes
Yes
No
Yes
Yes
No
Yes
No
No
Yes
Yes
No
Yes
Yes
Yes
No
No
Yes
No
No
No
Yes
No
Yes
No
Yes
Yes
Yes
No
No
Yes
Yes
No
No
Yes
Yes
Yes
No
No
No
Yes
Yes
No
Yes
No
Yes
No
Yes
No
Yes
Yes
No
Yes
No
No
Yes
Yes
Yes
No
Yes
No
Yes
No
Yes
No
No
No
No
Yes
Yes
No
No
No
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Yes
Yes
No
Yes...

result:

ok 10000 token(s): yes count is 5494, no count is 4506

Test #27:

score: 0
Accepted
time: 9ms
memory: 37800kb

input:

2
9561 4571
111111010
1000011001
1101111001110101110
000
100101
0100011001110
0010101101000001010
10
1101110101100001
10100001011001
11110001
001
1010101011001
000
111
101000110101000
1101
1100111100100110010
011001111010
10000010100111
00110100111111000
100
0001001
01010001
11110010010111
1100
1111...

output:

No
No

result:

ok 2 token(s): yes count is 0, no count is 2

Test #28:

score: 0
Accepted
time: 7ms
memory: 36968kb

input:

1
3445 1289
1
000111000
1101010111101111
1101010
0001100100101110011
1000010100010
01000100001
0000100
101001
1001001100
100111011000
1
001011100011010001
00101110000010000011
10111100110110
0
10011001
0
000011000111100
0110000111011000
00
101111101000000110
1
1111011
1100110
01000111
00010010110101...

output:

No

result:

ok NO

Test #29:

score: 0
Accepted
time: 4ms
memory: 41392kb

input:

1
9974 5595
1
001001101000100101
010011000011110
1010101101101010
0100010011
00010
010100100
010000111101110
10111000100001110110
1111010
0000111101
011101111110
1010000110111101110
0111101000011000
01111001011111
011011
000110100011001
10001100010011
01001100110001110
0110000110000
1
0100100111
101...

output:

No

result:

ok NO

Test #30:

score: 0
Accepted
time: 7ms
memory: 42156kb

input:

1
13292 19609
00110010111110100
01111000101
1101110111101111
1000101110
111010
0001
10100111110101001
1001010110101
0101100111001001110
01110101000000000
01111000111001110
00
00110010111111101101
01111111111001
0001111001011111
00111001100111
10011110111010101
1100110111101
0
000101100000000
1000000...

output:

No

result:

ok NO

Test #31:

score: 0
Accepted
time: 76ms
memory: 157412kb

input:

1
2 2
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

No

result:

ok NO

Test #32:

score: 0
Accepted
time: 27ms
memory: 102080kb

input:

1
2 1
100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes

result:

ok YES

Test #33:

score: 0
Accepted
time: 69ms
memory: 59624kb

input:

1
99832 168
111101100111100011010011011000101011110101111010110111100001110110101111101000000111010111010101010110010111010011010011111001010111101100011110100111111100100111011101101001100011010101001001001001110100000000111001011111100010111101101010001000001001100111000001111001111000101100111010...

output:

No

result:

ok NO

Test #34:

score: 0
Accepted
time: 75ms
memory: 59128kb

input:

1
99878 122
100111011100110101011100111101110011000011000111111000010110000100000001010011000000110110111110001010001000101010101010000111001011100111111001111011101001100001011011001011010111100110111100010011010101100001100010110101010000001101100000011000011101010000101111011011101110100100101011...

output:

No

result:

ok NO

Test #35:

score: 0
Accepted
time: 75ms
memory: 58892kb

input:

1
99856 144
010111100111010000110100000010010011110010111001100011100111011001101100110011100011100111100111110010110110000010110100110000010110100110110100000011110111111110001000100000110101100001011110011110100000110000000000011100000100100010011001111100101101100110110011011000101010001001101001...

output:

Yes

result:

ok YES

Test #36:

score: 0
Accepted
time: 70ms
memory: 59376kb

input:

1
99869 131
001111011110011011101011011111101000010101000110111000010111000001100001001000101110100110011110111000100100111111000000111110110010010001100001011010010111100000000111000010101000010001101101011110100001000001110011100011000010010010001011101001111110001011011000000110011101110011111010...

output:

No

result:

ok NO

Test #37:

score: 0
Accepted
time: 74ms
memory: 59144kb

input:

1
99847 153
111101000100001111100000110011110100100001111001100111100000010101001001101101101000010101010101100101011001001100101110001000101010010000101100010010001011100110100101101010011110010110101000010110000000111100001010101001110101101110010001010101011010111100010110000101011001110011101010...

output:

Yes

result:

ok YES

Test #38:

score: 0
Accepted
time: 73ms
memory: 62792kb

input:

1
99825 175
100101110111101000001110000110000111010000000110101110010001001111100110010111100111011100100100111101000111110100110010111010000110111011110111101110010011111100110010110101101110000111011011001111101101011101111000000010110101001101111010010000001010000011110000000011001011011010010001...

output:

No

result:

ok NO

Test #39:

score: 0
Accepted
time: 72ms
memory: 58640kb

input:

1
99871 129
010101001100100001011111101001111111100111111011110101100011110111001011110110000110111101101101001011111100011101001000000100011010101111110010110110110100101011111001010111010000110000111100000111001100001110101011101001000011110101100010000100111010010101101110101010011111110010010001...

output:

No

result:

ok NO

Test #40:

score: 0
Accepted
time: 63ms
memory: 59760kb

input:

1
99884 116
100100100100000111000111011010011001110110111010101100010100101100101011101111010111101000101011110100001000111010110110010111010010000100100011100100100110110000111000011000110010001010110001000111001110101101111111001011100101110100110000011001001010011101011011101101101011011111100001...

output:

Yes

result:

ok YES