QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#446958#8467. Binary StringssuomynonAAC ✓126ms239728kbC++203.3kb2024-06-17 19:03:542024-06-17 19:03:54

Judging History

你现在查看的是测评时间为 2024-06-17 19:03:54 的历史记录

  • [2024-06-21 13:11:16]
  • 管理员手动重测本题所有提交记录
  • 测评结果:AC
  • 用时:99ms
  • 内存:239592kb
  • [2024-06-17 19:03:54]
  • 评测
  • 测评结果:100
  • 用时:126ms
  • 内存:239728kb
  • [2024-06-17 19:03:54]
  • 提交

answer

#include <bits/stdc++.h>
const int N = 1e6;
int n, m, a[N + 5], chk[N + 5];
void merge(int &x, int y) {
    if (x != 2 and y) {
        if (y == 2 or !x) x = y;
        else if (x != y) x = 2;
    }
}
std::string s;
std::vector<int> v[N + 5], nxt[N + 5];
namespace ACAM {

struct Node { int sn[2], fail, c, k; }ar[N + 5];
int n;
void insert(int op) {
    int p = 0;
    for (auto i : s) {
        int x = i - '0';
        if (!ar[p].sn[x]) ar[p].sn[x] = ++n;
        p = ar[p].sn[x];
    }
    if (op) {
        if (ar[p].c) ar[p].c = 2;
        else ar[p].c = -p;
    }else ar[p].k = 1;
}
std::queue<int> que;
void build() {
    for (auto i : {0, 1}) if (ar[0].sn[i]) que.push(ar[0].sn[i]);
    while (que.size()) {
        int p = que.front();
        que.pop();
        ar[p].k |= ar[ar[p].fail].k;
        merge(ar[p].c, ar[ar[p].fail].c);
        for (auto i : {0, 1}) {
            if (ar[p].sn[i]) {
                ar[ar[p].sn[i]].fail = ar[ar[p].fail].sn[i];
                ar[ar[p].sn[i]].k |= ar[p].k;
                merge(ar[ar[p].sn[i]].c, ar[p].c);
                que.push(ar[p].sn[i]);
            }else ar[p].sn[i] = ar[ar[p].fail].sn[i];
        }
    }
    for (int i = 0; i <= n; ++i) chk[i] = ar[i].k, a[i] = ar[i].c;
    for (int i = 0; i <= n; ++i) if (!chk[i])
        for (auto j : {0, 1}) if (!chk[ar[i].sn[j]]) v[i].push_back(ar[i].sn[j]);
}
void clear() {
    for (int i = 0; i <= n; ++i)
        ar[i].sn[0] = ar[i].sn[1] = ar[i].fail = ar[i].c = ar[i].k = 0;
    n = 0;
}

}
int dfn[N + 5], low[N + 5], ind;
std::stack<int> sta;
bool ins[N + 5];
int sum[N + 5], col[N + 5], cnt;
void tarjan(int x) {
    dfn[x] = low[x] = ++ind, sta.push(x), ins[x] = 1;
    for (auto i : v[x]) {
        if (!dfn[i]) tarjan(i), low[x] = std::min(low[x], low[i]);
        else if (ins[i]) low[x] = std::min(low[x], dfn[i]);
    }
    if (dfn[x] == low[x]) {
        ++cnt;
        while (sta.top() != x) {
            col[sta.top()] = cnt, merge(sum[cnt], a[sta.top()]);
            ins[sta.top()] = 0, sta.pop();
        }
        col[x] = cnt, merge(sum[cnt], a[x]), ins[x] = 0, sta.pop();
    }
}
int f[N + 5];
void solve() {
    std::cin >> n >> m;
    for (int i = 1; i <= n; ++i) std::cin >> s, ACAM::insert(1);
    for (int i = 1; i <= m; ++i) std::cin >> s, ACAM::insert(0);
    ACAM::build(), n = ACAM::n; tarjan(0);
    for (int i = 0; i <= n; ++i) if (col[i])
        for (auto j : v[i]) if (col[i] != col[j]) nxt[col[i]].push_back(col[j]);
    for (int i = 1; i <= cnt; ++i) {
        for (auto j : nxt[i]) if (f[j] == 2 or sum[i] == 2) f[i] = 2;
        for (auto j : nxt[i]) if (sum[i] and f[j] and sum[i] != f[j]) f[i] = 2;
        if (f[i] == 2) continue;
        f[i] = sum[i];
        for (auto j : nxt[i]) if (f[j]) {
            if (f[i] and f[i] != f[j]) f[i] = 1;
            else f[i] = f[j];
        }
    }
    std::cout << (f[col[0]] == 2 ? "Yes\n" : "No\n");
    for (int i = 0; i <= n; ++i) {
        col[i] = a[i] = dfn[i] = sum[i] = f[i] = 0, chk[i] = 0;
        nxt[i].clear(), v[i].clear();
    }
    ind = cnt = 0;
    ACAM::clear();
}
int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0);
    int _;
    for (std::cin >> _; _--;) solve();
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 13812kb

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: 0ms
memory: 14056kb

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: 18ms
memory: 15864kb

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

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: 25ms
memory: 13852kb

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

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: 25ms
memory: 13776kb

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

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

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: 17ms
memory: 15924kb

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: 21ms
memory: 15968kb

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

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

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: 25ms
memory: 16176kb

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

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: 17ms
memory: 13880kb

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

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: 19ms
memory: 15868kb

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

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

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

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

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

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

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

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

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: 3ms
memory: 16816kb

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: 0ms
memory: 16208kb

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: 5ms
memory: 14480kb

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: 3ms
memory: 14992kb

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: 126ms
memory: 239728kb

input:

1
2 2
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

No

result:

ok NO

Test #32:

score: 0
Accepted
time: 49ms
memory: 108232kb

input:

1
2 1
100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes

result:

ok YES

Test #33:

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

input:

1
99832 168
111101100111100011010011011000101011110101111010110111100001110110101111101000000111010111010101010110010111010011010011111001010111101100011110100111111100100111011101101001100011010101001001001001110100000000111001011111100010111101101010001000001001100111000001111001111000101100111010...

output:

No

result:

ok NO

Test #34:

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

input:

1
99878 122
100111011100110101011100111101110011000011000111111000010110000100000001010011000000110110111110001010001000101010101010000111001011100111111001111011101001100001011011001011010111100110111100010011010101100001100010110101010000001101100000011000011101010000101111011011101110100100101011...

output:

No

result:

ok NO

Test #35:

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

input:

1
99856 144
010111100111010000110100000010010011110010111001100011100111011001101100110011100011100111100111110010110110000010110100110000010110100110110100000011110111111110001000100000110101100001011110011110100000110000000000011100000100100010011001111100101101100110110011011000101010001001101001...

output:

Yes

result:

ok YES

Test #36:

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

input:

1
99869 131
001111011110011011101011011111101000010101000110111000010111000001100001001000101110100110011110111000100100111111000000111110110010010001100001011010010111100000000111000010101000010001101101011110100001000001110011100011000010010010001011101001111110001011011000000110011101110011111010...

output:

No

result:

ok NO

Test #37:

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

input:

1
99847 153
111101000100001111100000110011110100100001111001100111100000010101001001101101101000010101010101100101011001001100101110001000101010010000101100010010001011100110100101101010011110010110101000010110000000111100001010101001110101101110010001010101011010111100010110000101011001110011101010...

output:

Yes

result:

ok YES

Test #38:

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

input:

1
99825 175
100101110111101000001110000110000111010000000110101110010001001111100110010111100111011100100100111101000111110100110010111010000110111011110111101110010011111100110010110101101110000111011011001111101101011101111000000010110101001101111010010000001010000011110000000011001011011010010001...

output:

No

result:

ok NO

Test #39:

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

input:

1
99871 129
010101001100100001011111101001111111100111111011110101100011110111001011110110000110111101101101001011111100011101001000000100011010101111110010110110110100101011111001010111010000110000111100000111001100001110101011101001000011110101100010000100111010010101101110101010011111110010010001...

output:

No

result:

ok NO

Test #40:

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

input:

1
99884 116
100100100100000111000111011010011001110110111010101100010100101100101011101111010111101000101011110100001000111010110110010111010010000100100011100100100110110000111000011000110010001010110001000111001110101101111111001011100101110100110000011001001010011101011011101101101011011111100001...

output:

Yes

result:

ok YES