QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#863717#9980. Boolean Function ReconstructionqianyueAC ✓1234ms4224kbC++142.6kb2025-01-19 21:35:462025-01-19 21:35:46

Judging History

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

  • [2025-01-19 21:35:46]
  • 评测
  • 测评结果:AC
  • 用时:1234ms
  • 内存:4224kb
  • [2025-01-19 21:35:46]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define ckmin(a, b) (a) = ((b) < (a) ? (b) : (a))
#define ckmax(a, b) (a) = ((b) > (a) ? (b) : (a))

static int global_n;

inline vector<int> Subset(int S) {
    vector<int> v;
    for (int T = S; T; T = (T - 1) & S) v.push_back(T ^ S);
    return v;
}

inline vector<int> Bitset(int S) {
    vector<int> v;
    for (int i = 0; i < global_n; i++) if (S >> i & 1) v.push_back(i);
    return v;
}
inline string And_merge(const string &a, const string &b) {
    string s;
    if (a.empty()) return b;
    if (b.empty()) return a;
    s += '(';
    s += a;
    s += '&';
    s += b;
    s += ')';
    return s;
}
inline string Or_merge(const string &a, const string &b) {
    string s;
    if (a.empty()) return b;
    if (b.empty()) return a;
    s += '(';
    s += a;
    s += '|';
    s += b;
    s += ')';
    return s;
}
template<class T>
void debug(vector<T>v) {
    for (int x : v) cout << x << ' ';
    cout << '\n';
}

void solve() {
    int n;
    string table;
    cin >> n >> table;

    const int N = 1 << n;
    if (table == string(N, '0')) {
        cout << "Yes\nF\n";
        return;
    }
    if (table == string(N, '1')) {
        cout << "Yes\nT\n";
        return;
    }


    global_n = n;

    vector<int> expr;
    for (int S = 0; S < N; S++) {
        bool has_sub = false;
        for (int &T: Subset(S)) {
            if (table[T] == '1') has_sub = true;
        }
        if (!has_sub && table[S] == '1') expr.push_back(S);

        if (has_sub && table[S] == '0') {
            cout << "No\n";
            return;
        }
    }

    function<string(vector<int>, int)> Get_expression = [&](vector<int>expr, int I) -> string {
        if (I == n) {
            return "";
        }
        vector<int> f1, f2;
        for (int S : expr) ((S >> I & 1) ? f1 : f2).push_back(S);

        // cout << "expr,now:\n";
        // debug(expr);
        // cout << "debug f1 f2:\n";
        // debug(f1);
        // debug(f2);
        // cout << "debug,end\n\n";

        if (f1.empty()) {
            return Get_expression(f2, I + 1);
        }
        if (f2.empty()) {
            return And_merge(string(1, 'a' + I), Get_expression(f1, I + 1));
        }
        return Or_merge(And_merge(string(1, 'a' + I), Get_expression(f1, I + 1)), Get_expression(f2, I + 1));
    };

    cout << "Yes\n";
    cout << Get_expression(expr, 0) << '\n';
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int tc;
    cin >> tc;
    while (tc--) {
        solve();
    }

    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3712kb

input:

7
2
0001
2
0111
2
1111
3
00010111
1
10
2
0101
5
00000000000000000000000000000001

output:

Yes
(a&b)
Yes
(a|b)
Yes
T
Yes
((a&(b|c))|(b&c))
No
Yes
a
Yes
(a&(b&(c&(d&e))))

result:

ok 7 lines, tightest: 4 out of 14 (7 test cases)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

4
1
00
1
10
1
01
1
11

output:

Yes
F
No
Yes
a
Yes
T

result:

ok 4 lines, tightest: 0 out of 11 (4 test cases)

Test #3:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

16
2
0000
2
1000
2
0100
2
1100
2
0010
2
1010
2
0110
2
1110
2
0001
2
1001
2
0101
2
1101
2
0011
2
1011
2
0111
2
1111

output:

Yes
F
No
No
No
No
No
No
No
Yes
(a&b)
No
Yes
a
No
Yes
b
No
Yes
(a|b)
Yes
T

result:

ok 16 lines, tightest: 1 out of 12 (16 test cases)

Test #4:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

256
3
00000000
3
10000000
3
01000000
3
11000000
3
00100000
3
10100000
3
01100000
3
11100000
3
00010000
3
10010000
3
01010000
3
11010000
3
00110000
3
10110000
3
01110000
3
11110000
3
00001000
3
10001000
3
01001000
3
11001000
3
00101000
3
10101000
3
01101000
3
11101000
3
00011000
3
10011000
3
01011000...

output:

Yes
F
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
...

result:

ok 256 lines, tightest: 4 out of 14 (256 test cases)

Test #5:

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

input:

65536
4
0000000000000000
4
1000000000000000
4
0100000000000000
4
1100000000000000
4
0010000000000000
4
1010000000000000
4
0110000000000000
4
1110000000000000
4
0001000000000000
4
1001000000000000
4
0101000000000000
4
1101000000000000
4
0011000000000000
4
1011000000000000
4
0111000000000000
4
1111000...

output:

Yes
F
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
...

result:

ok 65536 lines, tightest: 8 out of 18 (65536 test cases)

Test #6:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

168
4
0000000000000000
4
0000000000000001
4
0000000000000011
4
0000000000000101
4
0000000000000111
4
0000000000001111
4
0000000000010001
4
0000000000010011
4
0000000000010101
4
0000000000010111
4
0000000000011111
4
0000000000110011
4
0000000000110111
4
0000000000111111
4
0000000001010101
4
000000000...

output:

Yes
F
Yes
(a&(b&(c&d)))
Yes
(b&(c&d))
Yes
(a&(c&d))
Yes
((a&(c&d))|(b&(c&d)))
Yes
(c&d)
Yes
(a&(b&d))
Yes
((a&(b&d))|(b&(c&d)))
Yes
(a&((b&d)|(c&d)))
Yes
((a&((b&d)|(c&d)))|(b&(c&d)))
Yes
((a&(b&d))|(c&d))
Yes
(b&d)
Yes
((a&(c&d))|(b&d))
Yes
((b&d)|(c&d))
Yes
(a&d)
Yes
((a&d)|(b&(c&d)))
Yes
((a&d)|(...

result:

ok 168 lines, tightest: 8 out of 18 (168 test cases)

Test #7:

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

input:

7581
5
00000000000000000000000000000000
5
00000000000000000000000000000001
5
00000000000000000000000000000011
5
00000000000000000000000000000101
5
00000000000000000000000000000111
5
00000000000000000000000000001111
5
00000000000000000000000000010001
5
00000000000000000000000000010011
5
0000000000000...

output:

Yes
F
Yes
(a&(b&(c&(d&e))))
Yes
(b&(c&(d&e)))
Yes
(a&(c&(d&e)))
Yes
((a&(c&(d&e)))|(b&(c&(d&e))))
Yes
(c&(d&e))
Yes
(a&(b&(d&e)))
Yes
((a&(b&(d&e)))|(b&(c&(d&e))))
Yes
(a&((b&(d&e))|(c&(d&e))))
Yes
((a&((b&(d&e))|(c&(d&e))))|(b&(c&(d&e))))
Yes
((a&(b&(d&e)))|(c&(d&e)))
Yes
(b&(d&e))
Yes
((a&(c&(d&e)...

result:

ok 7581 lines, tightest: 18 out of 26 (7581 test cases)

Test #8:

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

input:

14
1
01
2
0111
3
00010111
4
0001011101111111
5
00000001000101110001011101111111
6
0000000100010111000101110111111100010111011111110111111111111111
7
00000000000000010000000100010111000000010001011100010111011111110000000100010111000101110111111100010111011111110111111111111111
8
00000000000000010000...

output:

Yes
a
Yes
(a|b)
Yes
((a&(b|c))|(b&c))
Yes
((a&(b|(c|d)))|((b&(c|d))|(c&d)))
Yes
((a&((b&(c|(d|e)))|((c&(d|e))|(d&e))))|((b&((c&(d|e))|(d&e)))|(c&(d&e))))
Yes
((a&((b&(c|(d|(e|f))))|((c&(d|(e|f)))|((d&(e|f))|(e&f)))))|((b&((c&(d|(e|f)))|((d&(e|f))|(e&f))))|((c&((d&(e|f))|(e&f)))|(d&(e&f)))))
Yes
((a&...

result:

ok 14 lines, tightest: 68 out of 74 (14 test cases)

Test #9:

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

input:

14
1
01
2
0001
3
00010111
4
0000000100010111
5
00000001000101110001011101111111
6
0000000000000001000000010001011100000001000101110001011101111111
7
00000000000000010000000100010111000000010001011100010111011111110000000100010111000101110111111100010111011111110111111111111111
8
00000000000000000000...

output:

Yes
a
Yes
(a&b)
Yes
((a&(b|c))|(b&c))
Yes
((a&((b&(c|d))|(c&d)))|(b&(c&d)))
Yes
((a&((b&(c|(d|e)))|((c&(d|e))|(d&e))))|((b&((c&(d|e))|(d&e)))|(c&(d&e))))
Yes
((a&((b&((c&(d|(e|f)))|((d&(e|f))|(e&f))))|((c&((d&(e|f))|(e&f)))|(d&(e&f)))))|((b&((c&((d&(e|f))|(e&f)))|(d&(e&f))))|(c&(d&(e&f)))))
Yes
((a&...

result:

ok 14 lines, tightest: 68 out of 74 (14 test cases)

Test #10:

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

input:

14
1
00
2
0001
3
00000001
4
0000000100010111
5
00000000000000010000000100010111
6
0000000000000001000000010001011100000001000101110001011101111111
7
00000000000000000000000000000001000000000000000100000001000101110000000000000001000000010001011100000001000101110001011101111111
8
00000000000000000000...

output:

Yes
F
Yes
(a&b)
Yes
(a&(b&c))
Yes
((a&((b&(c|d))|(c&d)))|(b&(c&d)))
Yes
((a&((b&((c&(d|e))|(d&e)))|(c&(d&e))))|(b&(c&(d&e))))
Yes
((a&((b&((c&(d|(e|f)))|((d&(e|f))|(e&f))))|((c&((d&(e|f))|(e&f)))|(d&(e&f)))))|((b&((c&((d&(e|f))|(e&f)))|(d&(e&f))))|(c&(d&(e&f)))))
Yes
((a&((b&((c&((d&(e|(f|g)))|((e&(...

result:

ok 14 lines, tightest: 33 out of 42 (14 test cases)

Test #11:

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

input:

14
1
00
2
0000
3
00000001
4
0000000000000001
5
00000000000000010000000100010111
6
0000000000000000000000000000000100000000000000010000000100010111
7
00000000000000000000000000000001000000000000000100000001000101110000000000000001000000010001011100000001000101110001011101111111
8
00000000000000000000...

output:

Yes
F
Yes
F
Yes
(a&(b&c))
Yes
(a&(b&(c&d)))
Yes
((a&((b&((c&(d|e))|(d&e)))|(c&(d&e))))|(b&(c&(d&e))))
Yes
((a&((b&((c&((d&(e|f))|(e&f)))|(d&(e&f))))|(c&(d&(e&f)))))|(b&(c&(d&(e&f)))))
Yes
((a&((b&((c&((d&(e|(f|g)))|((e&(f|g))|(f&g))))|((d&((e&(f|g))|(f&g)))|(e&(f&g)))))|((c&((d&((e&(f|g))|(f&g)))|(e...

result:

ok 14 lines, tightest: 0 out of 11 (14 test cases)

Test #12:

score: 0
Accepted
time: 25ms
memory: 4224kb

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&((g&(h|(i|(j|(k|(l|(m|(n|o))))))))|((h&(i|(j|(k|(l|(m|(n|o)))))))|((i&(j|(k|(l|(m|(n|o))))))|((j&(k|(l|(m|(n|o)))))|((k&(l|(m|(n|o))))|((l&(m|(n|o)))|((m&(n|o))|(n&o)))))))))|((g&((h&(i|(j|(k|(l|(m|(n|o)))))))|((i&(j|(k|(l|(m|(n|o))))))|((j&(k|(l|(m|(n|o)))))|((k&(l|(m|(n...

result:

ok 1 lines, tightest: 12868 out of 16394 (1 test case)

Test #13:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000100000000000000010000000100010111000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&(g|(h|(i|(j|(k|(l|(m|(n|o)))))))))|((g&(h|(i|(j|(k|(l|(m|(n|o))))))))|((h&(i|(j|(k|(l|(m|(n|o)))))))|((i&(j|(k|(l|(m|(n|o))))))|((j&(k|(l|(m|(n|o)))))|((k&(l|(m|(n|o))))|((l&(m|(n|o)))|((m&(n|o))|(n&o))))))))))|((f&((g&(h|(i|(j|(k|(l|(m|(n|o))))))))|((h&(i|(j|(k|(l|(m|(n|...

result:

ok 1 lines, tightest: 11438 out of 16394 (1 test case)

Test #14:

score: 0
Accepted
time: 25ms
memory: 4096kb

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&((g&((h&(i|(j|(k|(l|(m|(n|o)))))))|((i&(j|(k|(l|(m|(n|o))))))|((j&(k|(l|(m|(n|o)))))|((k&(l|(m|(n|o))))|((l&(m|(n|o)))|((m&(n|o))|(n&o))))))))|((h&((i&(j|(k|(l|(m|(n|o))))))|((j&(k|(l|(m|(n|o)))))|((k&(l|(m|(n|o))))|((l&(m|(n|o)))|((m&(n|o))|(n&o)))))))|((i&((j&(k|(l|(m|(...

result:

ok 1 lines, tightest: 11438 out of 16394 (1 test case)

Test #15:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&((g&((h&((i&(j|(k|(l|(m|(n|o))))))|((j&(k|(l|(m|(n|o)))))|((k&(l|(m|(n|o))))|((l&(m|(n|o)))|((m&(n|o))|(n&o)))))))|((i&((j&(k|(l|(m|(n|o)))))|((k&(l|(m|(n|o))))|((l&(m|(n|o)))|((m&(n|o))|(n&o))))))|((j&((k&(l|(m|(n|o))))|((l&(m|(n|o)))|((m&(n|o))|(n&o)))))|((k&((l&(m|(n|o...

result:

ok 1 lines, tightest: 8006 out of 16394 (1 test case)

Test #16:

score: 0
Accepted
time: 498ms
memory: 3712kb

input:

65536
6
0000001101111111000111111111111101111111111111111111111111111111
6
0000000000000000000100110011011100000000000000000001001100111111
6
0101010101110111011101111111111101110111111111111111111111111111
6
0000001100000011000000110001011100011111001111110011111100111111
6
000000010001011100000001...

output:

Yes
((a&((b&e)|(d|f)))|((b&(c|(d|f)))|((c&(d|(e|f)))|((d&(e|f))|(e&f)))))
Yes
((a&((b&e)|(c&(d&e))))|((b&((c&e)|(d&e)))|(c&(d&(e&f)))))
Yes
(a|((b&(d|(e|f)))|((d&(e|f))|(e&f))))
Yes
((a&((b&((d&e)|f))|(c&(d&e))))|((b&(c|((d&f)|(e&f))))|(c&f)))
Yes
((a&((b&(c|(d|f)))|(c&(d|f))))|(b&((c&(d|f))|(d&f)))...

result:

ok 65536 lines, tightest: 33 out of 42 (65536 test cases)

Test #17:

score: 0
Accepted
time: 1109ms
memory: 3712kb

input:

65536
7
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
7
00000001000100010001000101110111000100010111011101110111011111110001000101110111011101110111111100010001011101110111011111111111
7
000000010001001100000001001101...

output:

Yes
(a&(b&(c&(d&(e&(f&g))))))
Yes
((a&((b&(c|(d|(e|(f|g)))))|((d&(e|(f|g)))|(e&(f|g)))))|((b&((d&(e|(f|g)))|(e&(f|g))))|((c&(d&(e&(f|g))))|(d&(e&(f&g))))))
Yes
((a&((b&(c|(d|f)))|((c&((d&e)|(e&f)))|(d&f))))|((b&((c&(d|((e&g)|f)))|((d&(e|f))|(e&f))))|((c&(d&f))|(d&(e&(f&g))))))
Yes
((a&((b&(c&(d|f)))...

result:

ok 65536 lines, tightest: 68 out of 74 (65536 test cases)

Test #18:

score: 0
Accepted
time: 599ms
memory: 3584kb

input:

16384
8
0000000000000000000000000000000000000000000000000000000000010001000000000000000000000000000100010000000000010001000100010011011100000000000000000000000000010001000000000001000100010001011101110000000000000001000100010011011100010001000101110011011101111111
8
000101010101011100010101011101110...

output:

Yes
((a&((b&((c&(d&(g&h)))|((d&((e&(f|(g|h)))|(f&(g|h))))|((e&((f&(g|h))|(g&h)))|(f&(g&h))))))|((c&((d&((e&((f&g)|(g&h)))|(f&(g&h))))|(e&(f&(g&h)))))|(d&(e&(f&h))))))|((b&((c&(d&(f&(g&h))))|((d&(e&((f&(g|h))|(g&h))))|(e&(f&(g&h))))))|(c&(d&(e&(f&(g&h)))))))
Yes
((a&(b|(c|(d|(f|(g|h))))))|((b&((c&(d|...

result:

ok 16384 lines, tightest: 117 out of 138 (16384 test cases)

Test #19:

score: 0
Accepted
time: 343ms
memory: 3712kb

input:

4096
9
00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000001000101110000000000000000000000010001011100000...

output:

Yes
((a&((b&((c&((d&((e&f)|(f&i)))|((e&((f&(g&h))|i))|(f&(g&i)))))|((d&((e&((f&(g&h))|i))|(f&(g&i))))|(e&(g&i)))))|((c&((d&((e&((f&g)|i))|(f&(g&i))))|(e&(g&i))))|((d&(e&(g&i)))|(e&(f&i))))))|((b&((c&((d&((e&((f&g)|i))|(f&(g&i))))|(e&(g&i))))|((d&(e&(g&i)))|(e&(f&i)))))|((c&((d&(e&((g&i)|(h&i))))|(e&...

result:

ok 4096 lines, tightest: 238 out of 266 (4096 test cases)

Test #20:

score: 0
Accepted
time: 203ms
memory: 3712kb

input:

1024
10
0000000000000000000000000000000100000000000000110000000000000011000000000000000100000000000000110000000000000011000000010000001100000000000000110000000000000011000000000000001100000011000001110000000000000011000000000000001100000011000001110000001100011111000000000000001100000000000000110000...

output:

Yes
((a&((b&((c&((d&(e|g))|((e&((f&g)|(g&(h&i))))|((f&i)|j))))|((d&((e&((f&(g&h))|j))|((f&((g&i)|(h&i)))|((g&j)|(h&j)))))|((e&((f&(h&j))|(g&(h&(i&j)))))|(f&(g&(h&j)))))))|((c&((d&((e&((f&h)|(g&(h&i))))|((f&((g&h)|i))|j)))|((e&(h&(i&j)))|((f&(h&j))|(g&(h&(i&j)))))))|(d&(e&(f&(i&j)))))))|((b&((c&((d&(...

result:

ok 1024 lines, tightest: 396 out of 522 (1024 test cases)

Test #21:

score: 0
Accepted
time: 123ms
memory: 3584kb

input:

256
11
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&(e&((f&(j&k))|(g&(h&(j&k))))))|(f&(h&i))))|((d&((e&(f&(h&i)))|(f&((g&(i&j))|(h&((i&k)|j))))))|(e&((f&((g&(h&((i&k)|j)))|(i&(j&k))))|(h&(i&(j&k))))))))|((c&(d&((e&(f&(h&((i&k)|j))))|(f&(g&(h&(j&k)))))))|((e&(f&(h&(i&j))))|(f&(h&(i&(j&k))))))))|((b&((c&((d&(f&(h&i)))|((e&(f&(h&i)))...

result:

ok 256 lines, tightest: 644 out of 1034 (256 test cases)

Test #22:

score: 0
Accepted
time: 78ms
memory: 3840kb

input:

64
12
000101011111111101111111111111110001011111111111011111111111111100010111111111110111111111111111000101111111111101111111111111110001010111111111011111111111111100010111111111110111111111111111000101111111111101111111111111110001011111111111111111111111111101111111111111111111111111111111011111...

output:

Yes
((a&(b|(c|(e|((f&l)|((g&(h&l))|(i|((j&l)|k))))))))|((b&((c&(f|(g|(j|l))))|(e|(i|k))))|((c&(e|((f&(g&(h&l)))|(i|((j&l)|k)))))|(d|((e&((f&(g&h))|(i|(j|(k|l)))))|((f&((g&(i&j))|((h&(i&j))|k)))|((g&(h&k))|((i&(k|l))|((j&k)|(k&l))))))))))
Yes
((a&((b&((c&((d&((e&(f|((i&j)|(j&(k&l)))))|((f&(g|(h|(i&(j...

result:

ok 64 lines, tightest: 1376 out of 2058 (64 test cases)

Test #23:

score: 0
Accepted
time: 50ms
memory: 3840kb

input:

16
13
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011000000000000000000000000000000000011111111111111111111111111111100000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&j)|((g&(j&(l|m)))|(i&(j&(k&(l&m)))))))|((f&(g&(i&k)))|(h&(j&l)))))|((e&((f&(j&l))|(h&j)))|((f&(g&(i&(l&m))))|(g&(h&(i&k)))))))|((d&((e&((f&(h&k))|(g&(h&(k&(l|m))))))|((f&(i&(j&(l|m))))|(h&((i&j)|(j&(k&(l&m))))))))|((e&((f&((h&((k&l)|(l&m)))|((i&j)|(j&(k&(l&m))))))|(g&(i&(...

result:

ok 16 lines, tightest: 1730 out of 4106 (16 test cases)

Test #24:

score: 0
Accepted
time: 35ms
memory: 3968kb

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((e&((f&((h&((i&n)|l))|((k&m)|(l&n))))|((h&((i&(j&(k|(m&n))))|(k&(l&m))))|((i&((k&l)|(l&m)))|(j&((k&l)|(l&m)))))))|((f&((h&((i&(j|((k&n)|(m&n))))|((j&(k&n))|(l&m))))|((i&(j&n))|((k&l)|(l&(m&n))))))|((h&(i&(j&((k&m)|(l&n)))))|((i&(k&(l&m)))|(j&(k&(l&m))))))))|((d&(e&((f&(h&(j&(m&n))))...

result:

ok 4 lines, tightest: 2117 out of 8202 (4 test cases)

Test #25:

score: 0
Accepted
time: 35ms
memory: 3968kb

input:

4
14
0000000000000000000000000000000000000000000000000001000100010101000000000000000101010101010101010001010101010101011101110111111100000000000000000000000000000001000000000000000000010101010101010000000100010001010101010101011101010101010101010111111111111111000000000000000000010101010101010000000...

output:

Yes
((a&((b&((c&((d&((e&(h|(k|(l|m))))|((f&(j|k))|(g|((h&((i&l)|(j&(k&l))))|((i&(j|k))|((j&n)|(k&n))))))))|((e&((h&k)|(j|(k&(l|m)))))|((f&((h&(j&l))|(i|((j&k)|n))))|((g&(h|(j|(k|l))))|((h&((i&((j&l)|(k&l)))|(j&(l&n))))|((i&((j&(k|(l&m)))|n))|(j&(k&n)))))))))|((d&((e&((h&k)|(j|(k&(l|m)))))|((f&((h&((...

result:

ok 4 lines, tightest: 1595 out of 8202 (4 test cases)

Test #26:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&(i&(m&n)))|((h&(k&(l&n)))|(i&(j&l)))))|(g&(j&(l&(m&n))))))|((e&((f&(g&(i&(j&(k&n)))))|(g&((h&(i&(k&(l&m))))|(k&(l&(m&n)))))))|(f&(i&(j&(l&n)))))))|((d&(e&(f&(g&(h&(j&(k&(l&n))))))))|(e&(f&(i&(j&(k&(l&(m&n))))))))))|((c&((d&((e&((f&(h&(l&(m&n))))|(g&(i&(j&(k&(m&n)))))))|((...

result:

ok 4 lines, tightest: 3963 out of 8202 (4 test cases)

Test #27:

score: 0
Accepted
time: 32ms
memory: 3968kb

input:

4
14
0000000000000000000000000001001100000000000000110000000000110011000000000011001100000000001100110000000000110011000000000011001100000000001100110000000000110011000000000011001100000000001100110001001100111111001100111111111100110011111111110011001111111111000000000011001100000011001101110000000...

output:

Yes
((a&((b&((c&((d&j)|((e&((f&((g&j)|l))|(g&(k|m))))|((f&(i|n))|(h&(j&(k|m)))))))|((d&e)|((e&((f&(j&l))|((g&(j&(k|m)))|(h&(k|m)))))|((f&((i&j)|((j&n)|((k&l)|(l&m)))))|((g&(h|(k&m)))|((k&n)|(m&n))))))))|((c&((d&((e&((f&((h&j)|(j&(k&m))))|(i|n)))|((f&((g&(j&(k|m)))|((h&(k|m))|((j&n)|(k&l)))))|(j&((k&...

result:

ok 4 lines, tightest: 1902 out of 8202 (4 test cases)

Test #28:

score: 0
Accepted
time: 35ms
memory: 3968kb

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000001000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&(h&n))|((h&m)|(k|(m&n)))))|((f&(g|(i|(k|(l|m)))))|((g&((h&n)|(i|(k|(l|m)))))|((h&(i|(k|(l|(m&n)))))|((i&(k|(l|(m|n))))|(j|((k&(l|(m|n)))|(l&(m|n))))))))))|((e&((f&((g&(h&(l|(m&n))))|((h&((i&m)|(l&m)))|((i&(k|(m&n)))|(l&(m&n))))))|(g&(l&m))))|((f&((g&((h&((i&n)|(k|(l&n))))...

result:

ok 4 lines, tightest: 2458 out of 8202 (4 test cases)

Test #29:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&((g&((h&((i&((j&((k&l)|((l&m)|n)))|((k&(n|o))|(m&o))))|((j&((k&(m&n))|(l&o)))|((k&(l&o))|(n&o)))))|((i&((j&((k&(l&o))|(n&o)))|(l&(n&o))))|((j&(k&(m&(n&o))))|(k&(l&(m&(n&o))))))))|((h&((i&((j&((k&((l&m)|n))|((m&n)|o)))|((k&(m&(n|o)))|((l&(n|o))|(n&o)))))|((j&((k&((l&(n|o))...

result:

ok 1 lines, tightest: 933 out of 16394 (1 test case)

Test #30:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&(h&(k&l)))|((g&((h&(i&k))|(j&(k&(l&n)))))|((j&(k&o))|(l&(n&o))))))|((f&((g&((i&(k&(n&o)))|(k&(l&(m&o)))))|((h&(i&(k&m)))|(j&(k&(l&(m&n)))))))|((g&((h&(j&(l&n)))|(i&(j&(k&(m&n))))))|(i&(m&(n&o)))))))|((e&((f&(g&(h&o)))|(h&(i&(k&(l&n))))))|((g&((h&(j&(k&(n&o))))|(i&(k&(l&(m...

result:

ok 1 lines, tightest: 2431 out of 16394 (1 test case)

Test #31:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&(g&(h|((j&l)|(n|o)))))|((h&((i&k)|(k&m)))|((i&(k&(n|o)))|(k&(m&(n|o)))))))|((f&((g&((h&((j&l)|(n|o)))|((i&(k&m))|((j&(l&(n|o)))|(n&o)))))|((h&((i&m)|((j&o)|(k&(l&(n|o))))))|((i&((j&(l&m))|(m&(n|o))))|((j&(n&o))|(k&(l&(n&o))))))))|((g&((i&((j&(l&m))|(m&(n|o))))|(k&(l&(n&o)...

result:

ok 1 lines, tightest: 4543 out of 16394 (1 test case)

Test #32:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000001100000000000000110000001100111111000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&((g&o)|k))|((g&k)|((j&(l&m))|((k&(l|m))|((l&n)|(m&n)))))))|((f&((g&(i|((j&k)|(l&m))))|((h&(l|m))|((i&(l|m))|((j&((k&((l&o)|(m&o)))|((l&n)|(m&n))))|(k&n))))))|((g&((h&(l|m))|((i&(l|m))|((j&((k&((l&o)|(m&o)))|((l&n)|(m&n))))|(k&n)))))|((h&(i|((j&(k|n))|(l&(m&o)))))|((i&(j&(...

result:

ok 1 lines, tightest: 3582 out of 16394 (1 test case)

Test #33:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&((g&((h&((i&(j&(l|n)))|((j&(m&n))|(k&(l|n)))))|((i&((j&((k&((l&n)|m))|(n&o)))|(l&o)))|((j&((k&((l&(m&n))|o))|(m&(n&o))))|((k&(n&o))|(l&(m&o)))))))|((h&((i&(k|((l&n)|m)))|((j&((k&(l|n))|(l&m)))|((k&((l&n)|m))|((l&(m&n))|o)))))|((i&((j&(l&o))|((k&((l&m)|(m&n)))|((l&(n&o))|(...

result:

ok 1 lines, tightest: 2496 out of 16394 (1 test case)

Test #34:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001010100000000000000000000000001010101000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&((g&j)|((i&(l&o))|((k&l)|((l&(m&o))|n)))))|((g&((i&(l|o))|((j&(l&o))|((l&m)|(m&o)))))|((i&(j&o))|(j&((l&m)|(m&o)))))))|((f&((g&((i&j)|((j&m)|((k&(l&o))|(n&o)))))|((h&((i&(l|o))|((j&(l&o))|((l&m)|(m&o)))))|((i&((k&(l|o))|(l&n)))|((j&(k&(l&o)))|(k&((l&m)|(m&o))))))))|((g&((...

result:

ok 1 lines, tightest: 3836 out of 16394 (1 test case)

Test #35:

score: 0
Accepted
time: 1234ms
memory: 3712kb

input:

65536
7
00000000000000010000000100000101000000000001011100000101010111110000000100000001000001110001011100000101001101110011011111111111
7
00000000000000010000000000010111000000000000011100000001011111110000000100000001000000110011011100010101001101110011111111111111
7
000000000000000000000001000100...

output:

Yes
((a&((b&((c&(d|(e|g)))|(d&((e&g)|f))))|((c&((d&(e|f))|((e&(f|g))|(f&g))))|(d&(e&f)))))|((b&((c&((d&f)|(e&g)))|((d&(f&g))|(e&(f&g)))))|((c&(d&(e&f)))|(d&(e&(f&g))))))
Yes
((a&((b&((c&(d|((e&f)|g)))|((d&e)|(f&g))))|((c&((d&(e|f))|(f&g)))|(d&(e&f)))))|((b&((c&((d&(e|f))|(e&g)))|((d&((e&(f|g))|(f&g)...

result:

ok 65536 lines, tightest: 62 out of 74 (65536 test cases)

Test #36:

score: 0
Accepted
time: 230ms
memory: 3840kb

input:

1024
10
0000000000000000000000000000000000000000000000000000000000000011000000000000000000000001000001110000000000000111000101010111011100000000000000000000000000000111000000010001011100010011000101110000000100000001000001110001011100000101011111110101111111111111000000000000000100000000000100010000...

output:

Yes
((a&((b&((c&((d&i)|((e&(g|j))|((f&(h|j))|((g&(h|j))|((h&i)|(i&j)))))))|((d&((e&((g&h)|(i|j)))|((f&(h|j))|(h&j))))|((e&((f&(g|(h|j)))|(h&j)))|((f&((g&(i|j))|(h&i)))|(g&(h&i)))))))|((c&((d&((e&(g|(h|j)))|(f&(g|(h|(i|j))))))|((e&((f&(g|j))|((g&h)|((h&i)|(i&j)))))|((f&((g&(h|(i|j)))|((h&j)|(i&j))))|...

result:

ok 1024 lines, tightest: 327 out of 522 (1024 test cases)

Test #37:

score: 0
Accepted
time: 85ms
memory: 3840kb

input:

64
12
000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000001000101110000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000010000000100010101000101110111111100000000000000000000000000000001000000...

output:

Yes
((a&((b&((c&((d&((e&(f|((g&h)|((h&k)|(i|j)))))|((f&k)|((g&(i|j))|((h&l)|((i&j)|(j&k)))))))|((e&((f&(g|(i|(k|l))))|((g&(i|(j|k)))|((h&l)|((i&j)|((j&(k|l))|(k&l)))))))|((f&((g&(h|k))|((h&(i|k))|((i&(j|(k|l)))|(k&l)))))|((g&((h&(j|(k|l)))|((i&l)|(j&l))))|((h&((i&(j|(k|l)))|(j&(k|l))))|(i&((j&k)|(k&...

result:

ok 64 lines, tightest: 1115 out of 2058 (64 test cases)

Test #38:

score: 0
Accepted
time: 82ms
memory: 3712kb

input:

64
12
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&(g|(h|j)))|((g&(j|k))|((h&(i|(j|l)))|((i&j)|((j&k)|(k&l)))))))|((f&((g&(k|l))|((h&k)|((i&(j|k))|((j&(k|l))|(k&l))))))|((g&((h&(j|l))|((i&(j|(k|l)))|((j&k)|(k&l)))))|((h&((i&(k|l))|((j&(k|l))|(k&l))))|(j&(k&l)))))))|((e&((f&((g&l)|((h&(j|k))|((i&(k|l))|((j&l)|(k&l))))))|((...

result:

ok 64 lines, tightest: 1110 out of 2058 (64 test cases)

Test #39:

score: 0
Accepted
time: 78ms
memory: 3840kb

input:

64
12
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&((g&(h|(i|(j|l))))|((h&(i|k))|((i&l)|((j&(k|l))|(k&l))))))|((g&((h&k)|((i&(j|(k|l)))|(k&l))))|((h&((i&j)|(j&l)))|((i&((j&k)|(k&l)))|(j&(k&l)))))))|((f&((g&((h&j)|((i&(j|l))|((j&(k|l))|(k&l)))))|((h&((i&(j|k))|(j&k)))|((i&(j&(k|l)))|(j&(k&l))))))|(g&(h&((i&(j|k))|(j&(k|l))...

result:

ok 64 lines, tightest: 839 out of 2058 (64 test cases)

Test #40:

score: 0
Accepted
time: 35ms
memory: 3968kb

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000010111000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&(g|(j|(k|(m&n)))))|((g&(i|(j|(k|n))))|((h&(k|(l|n)))|((i&(j|(l|n)))|((j&(k|(l|(m|n))))|(k&n)))))))|((f&((g&(h|(j|k)))|((h&(i|(k|(l|(m|n)))))|((i&m)|((j&(l|n))|((k&(l|n))|(l&n)))))))|((g&((h&(i|(j|l)))|((i&(j|(k|(l|m))))|((j&n)|((k&(l|m))|(l&m))))))|((h&((i&(j|m))|((j&(k|m...

result:

ok 4 lines, tightest: 3983 out of 8202 (4 test cases)

Test #41:

score: 0
Accepted
time: 36ms
memory: 3840kb

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&((g&(h|(j|(l|m))))|((h&(k|(m|n)))|((i&(k|n))|((j&(l|n))|((k&m)|((l&(m|n))|(m&n))))))))|((g&((h&(i|n))|((i&(j|(k|(m|n))))|((j&(k|m))|((k&l)|(l&(m|n)))))))|((h&((i&(l|n))|((j&k)|(k&l))))|((i&((j&(k|(m|n)))|((k&n)|(l&m))))|((j&((k&n)|((l&(m|n))|(m&n))))|((k&(l&n))|(l&(m&n)))...

result:

ok 4 lines, tightest: 3987 out of 8202 (4 test cases)

Test #42:

score: 0
Accepted
time: 25ms
memory: 4096kb

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000100000001000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&((i&n)|(l|(m|o))))|((g&(i|(j|l)))|((h&(k|(l|(n|o))))|((i&(k|l))|((j&(k|(n|o)))|((k&((l&o)|m))|((l&(m|n))|(n&o)))))))))|((f&((g&(h|(i|(j|(k|(l|(n|o)))))))|((h&(i|(j|(m|o))))|((i&(j|(k|o)))|((j&(k|m))|((k&(l|o))|((m&o)|(n&o))))))))|((g&((h&(i|(j|(l|(m|(n|o))))))|((i&(l|(m|(...

result:

ok 1 lines, tightest: 6910 out of 16394 (1 test case)

Test #43:

score: 0
Accepted
time: 25ms
memory: 3968kb

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&((g&(j|(k|l)))|((h&(j|(k|(l|o))))|((i&(j|(k|(l|n))))|((j&(m|o))|((k&l)|((m&o)|(n&o))))))))|((g&((h&(i|(k|(l|o))))|((i&(j|(k|(m|n))))|((j&(m|o))|((k&n)|((l&(m|(n|o)))|((m&n)|(n&o))))))))|((h&((i&(k|l))|((j&(k|(m|o)))|((m&(n|o))|(n&o)))))|((i&((j&(k|(l|(m|o))))|((k&(l|m))|(...

result:

ok 1 lines, tightest: 7822 out of 16394 (1 test case)

Test #44:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes
((a&((b&((c&((d&((e&((f&((g&((h&(j|(l|(n|o))))|((i&(n|o))|((j&(k|(m|n)))|((k&o)|((l&(m|o))|((m&o)|(n&o))))))))|((h&((i&(j|n))|((j&(m|o))|((k&(m|n))|((l&(m|n))|(m&(n|o)))))))|((i&((j&(l|m))|((k&(l|o))|(m&(n|o)))))|((j&((k&(l|(m|o)))|((l&(m|(n|o)))|((m&(n|o))|(n&o)))))|((k&((l&o)|(m&(n|o))))|((l&(...

result:

ok 1 lines, tightest: 6893 out of 16394 (1 test case)

Extra Test:

score: 0
Extra Test Passed