QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#447277#8467. Binary Stringsship2077AC ✓103ms242468kbC++172.5kb2024-06-18 08:35:312024-06-21 13:11:18

Judging History

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

  • [2024-06-21 13:11:18]
  • 管理员手动重测本题所有提交记录
  • 测评结果:AC
  • 用时:103ms
  • 内存:242468kb
  • [2024-06-18 08:35:32]
  • 评测
  • 测评结果:100
  • 用时:115ms
  • 内存:242352kb
  • [2024-06-18 08:35:31]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int M=1e6+5;
int n,m,T,idx,tp,num,tot;string str;
int ans[M][2],sum[M],dfn[M],low[M],stk[M],scc[M],deg[M];
int cur[M],tag[M],fail[M],tr[M][2];vector<int>adj[M],g[M];
int merge(int x,int y){return x==y?x:(x&&y?-1:x|y);}
void insert(string str,int type){
	int p=0,len=str.length();
	for (int i=0,ch;i<len;i++){
		if (!tr[p][ch=str[i]-'0'])
			tr[p][ch]=++idx,tr[idx][0]=tr[idx][1]=0,
			cur[idx]=tag[idx]=0;
		p=tr[p][ch];
	}
	if (type) cur[p]=merge(cur[p],type);
	else tag[p]=1;
}
void build(){ queue<int>q;
	for (auto i:{0,1})
		if (tr[0][i])
			fail[tr[0][i]]=0,
			q.emplace(tr[0][i]);
	while (!q.empty()){
		int x=q.front(),y;q.pop();
		cur[x]=merge(cur[x],cur[fail[x]]);tag[x]|=tag[fail[x]];
		for (auto i:{0,1}){int &y=tr[x][i];
			if (y) fail[y]=tr[fail[x]][i],q.emplace(y);
			else y=tr[fail[x]][i];
		}
	}
}
void Tarjan(int x){
	dfn[x]=low[x]=++num;stk[++tp]=x;
	for (auto y:adj[x]){
		if (!dfn[y]) Tarjan(y),low[x]=min(low[x],low[y]);
		if (!~scc[y]) low[x]=min(low[x],dfn[y]);
	}
	if (dfn[x]!=low[x]) return;
	scc[x]=tot;while (stk[tp]!=x)
		scc[stk[tp--]]=tot; tp--;tot++;
}
void insert(int p,int x){
	if (!ans[p][0]||ans[p][0]==x)
		ans[p][0]=x;
	else if (!ans[p][1]||ans[p][1]==x)
		ans[p][1]=x;
}
bool check(){ num=tot=tp=0;
	for (int i=0;i<=idx;i++) adj[i].clear(),g[i].clear();
	for (int i=0;i<=idx;i++) dfn[i]=low[i]=sum[i]=deg[i]=ans[i][0]=ans[i][1]=0,scc[i]=-1;
	for (int i=0;i<=idx;i++) if (!tag[i])
		for (auto j:{0,1}) if (!tag[tr[i][j]])
			adj[i].emplace_back(tr[i][j]);
	Tarjan(0);
	for (int i=0;i<=idx;i++) sum[scc[i]]=merge(sum[scc[i]],cur[i]);
	for (int i=0;i<=idx;i++)
		for (auto j:adj[i])
			if (scc[i]!=scc[j]&&~scc[i]&&~scc[j])
				g[scc[i]].emplace_back(scc[j]),deg[scc[j]]++;
	queue<int>q;q.emplace(scc[0]);
	while (!q.empty()){
		int x=q.front();q.pop();
		if (sum[x]==-1) return 1;
		if (sum[x]&&ans[x][0]&&sum[x]!=ans[x][0]) return 1;
		if (sum[x]&&ans[x][1]&&sum[x]!=ans[x][1]) return 1;
		if (sum[x]) insert(x,sum[x]);
		for (auto y:g[x]){
			if (ans[x][0]) insert(y,ans[x][0]);
			if (ans[x][1]) insert(y,ans[x][1]);
			if (!--deg[y]) q.emplace(y);
		}
	}
	return 0;
}
void solve(){
	cin>>n>>m;idx=tr[0][0]=tr[0][1]=0;
	for (int i=1;i<=n;i++) cin>>str,insert(str,i);
	for (int i=1;i<=m;i++) cin>>str,insert(str,0);
	build();puts(check()?"Yes":"No");
}
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>T;while (T--) solve();return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 4ms
memory: 72748kb

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: 4ms
memory: 72868kb

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: 32ms
memory: 72672kb

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: 30ms
memory: 72844kb

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: 29ms
memory: 71968kb

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: 30ms
memory: 72172kb

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: 39ms
memory: 71420kb

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: 37ms
memory: 72456kb

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: 23ms
memory: 71828kb

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: 22ms
memory: 72260kb

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: 26ms
memory: 72228kb

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: 27ms
memory: 71636kb

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: 31ms
memory: 72176kb

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: 31ms
memory: 72624kb

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: 28ms
memory: 72340kb

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: 22ms
memory: 72132kb

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: 24ms
memory: 72572kb

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: 26ms
memory: 72316kb

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: 23ms
memory: 72624kb

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: 24ms
memory: 72612kb

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: 72500kb

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: 16ms
memory: 72856kb

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: 22ms
memory: 72536kb

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: 15ms
memory: 72664kb

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: 20ms
memory: 71576kb

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: 22ms
memory: 73764kb

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: 11ms
memory: 75152kb

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: 72516kb

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: 12ms
memory: 73996kb

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: 15ms
memory: 74268kb

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: 103ms
memory: 242468kb

input:

1
2 2
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

No

result:

ok NO

Test #32:

score: 0
Accepted
time: 53ms
memory: 150520kb

input:

1
2 1
100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes

result:

ok YES

Test #33:

score: 0
Accepted
time: 24ms
memory: 94664kb

input:

1
99832 168
111101100111100011010011011000101011110101111010110111100001110110101111101000000111010111010101010110010111010011010011111001010111101100011110100111111100100111011101101001100011010101001001001001110100000000111001011111100010111101101010001000001001100111000001111001111000101100111010...

output:

No

result:

ok NO

Test #34:

score: 0
Accepted
time: 26ms
memory: 96444kb

input:

1
99878 122
100111011100110101011100111101110011000011000111111000010110000100000001010011000000110110111110001010001000101010101010000111001011100111111001111011101001100001011011001011010111100110111100010011010101100001100010110101010000001101100000011000011101010000101111011011101110100100101011...

output:

No

result:

ok NO

Test #35:

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

input:

1
99856 144
010111100111010000110100000010010011110010111001100011100111011001101100110011100011100111100111110010110110000010110100110000010110100110110100000011110111111110001000100000110101100001011110011110100000110000000000011100000100100010011001111100101101100110110011011000101010001001101001...

output:

Yes

result:

ok YES

Test #36:

score: 0
Accepted
time: 24ms
memory: 95044kb

input:

1
99869 131
001111011110011011101011011111101000010101000110111000010111000001100001001000101110100110011110111000100100111111000000111110110010010001100001011010010111100000000111000010101000010001101101011110100001000001110011100011000010010010001011101001111110001011011000000110011101110011111010...

output:

No

result:

ok NO

Test #37:

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

input:

1
99847 153
111101000100001111100000110011110100100001111001100111100000010101001001101101101000010101010101100101011001001100101110001000101010010000101100010010001011100110100101101010011110010110101000010110000000111100001010101001110101101110010001010101011010111100010110000101011001110011101010...

output:

Yes

result:

ok YES

Test #38:

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

input:

1
99825 175
100101110111101000001110000110000111010000000110101110010001001111100110010111100111011100100100111101000111110100110010111010000110111011110111101110010011111100110010110101101110000111011011001111101101011101111000000010110101001101111010010000001010000011110000000011001011011010010001...

output:

No

result:

ok NO

Test #39:

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

input:

1
99871 129
010101001100100001011111101001111111100111111011110101100011110111001011110110000110111101101101001011111100011101001000000100011010101111110010110110110100101011111001010111010000110000111100000111001100001110101011101001000011110101100010000100111010010101101110101010011111110010010001...

output:

No

result:

ok NO

Test #40:

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

input:

1
99884 116
100100100100000111000111011010011001110110111010101100010100101100101011101111010111101000101011110100001000111010110110010111010010000100100011100100100110110000111000011000110010001010110001000111001110101101111111001011100101110100110000011001001010011101011011101101101011011111100001...

output:

Yes

result:

ok YES