QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#861613#9980. Boolean Function Reconstructionucup-team3215#AC ✓240ms4096kbC++232.9kb2025-01-18 18:36:112025-01-18 18:36:12

Judging History

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

  • [2025-01-18 18:36:12]
  • 评测
  • 测评结果:AC
  • 用时:240ms
  • 内存:4096kb
  • [2025-01-18 18:36:11]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

string s, tmp;

string solve(int a, int l, int r) {
  int c0 = 0, c02 = 0, c1 = 0, c12 = 0;
  for (int i = l; i < (l | 1 << a); ++i) {
    c0 += s[i] == 1;
    c02 += s[i] == -1;
    c1 += s[i | 1 << a] == 1;
    c12 += s[i | 1 << a] == -1;
  }
  if (c0 && c1) return '(' + solve(a - 1, l, l | 1 << a) + "|(" + char('a' + a) + '&' + solve(a - 1, l | 1 << a, r) + "))";
  else if (!c0 && !c1) return "F";
  else if (c0 + c02 == 1 << a) return "T";
  else if (c0) return solve(a - 1, l, l | 1 << a);
  else if (c1 + c12 == 1 << a) return ""s + char('a' + a);
  else if (c1) return "("s + char('a' + a) + '&' + solve(a - 1, l | 1 << a, r) + ')';
  else return "F";
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  mt19937 rng(23123123);
  for (int tc = (cin >> tc, tc); tc--; ) {
    int n, k; cin >> n;// >> k;
    s.resize(1 << n);
    cin >> s;
    for (auto& c: s) c -= '0';
//    for (int i = 0; i < 1 << n; ++i) s[i] = __builtin_popcount(i) >= k;
    bool ok = 1;
    for (int i = 0; i < 1 << n; ++i) if (s[i])
    for (int j = 0; j < n; ++j) ok &= s[i | 1 << j];
    if (!ok) { cout << "No\n"; continue; }
    for (int i = 0; i < 1 << n; ++i) if (s[i])
    for (int j = 0; j < n; ++j) if (s[i | 1 << j] && !(i >> j & 1)) s[i | 1 << j] = -1;
    cout << "Yes\n";
    string pref = "", suf = "";
    vector<int> var(n);
    for (int i = 0; i < n; ++i) var[i] = i;
    string t;
    while (t = pref + solve(n - 1, 0, 1 << n), count(t.begin(), t.end(), '&') + count(t.begin(), t.end(), '|') > (1 << n - 1) + 10) {
      shuffle(var.begin(), var.end(), rng);
      tmp.assign(1 << n, '\1');
      int m = rng() % (1 << n - 1) | 1 << n - 1;
      for (int i = 0, j = -1; i < n; ++i) if (m & 1 << i) {
        for (int k = 0; k < 1 << n; ++k) if (!(k & (1 << i + 1) - (1 << j + 1))) tmp[k] = 0;
        j = i;
      }
      int ok = 1, opt = 0;
      for (int k = 0; k < 1 << n; ++k) if (tmp[k] && !s[k]) ok = 0; else if (tmp[k] && s[k] == 1) ++opt;
      if (!ok || opt < n - 1) continue;
      for (int k = 0; k < 1 << n; ++k) if (tmp[k] && s[k]) s[k] = -1;
      string cur0;
      for (int i = 0, j = -1; i < n; ++i) if (m & 1 << i) {
        string cur1;
        for (int k = j; k++ < i; ) {
          if (cur1.size()) cur1 = '(' + cur1 + '|' + char('a' + k) + ')';
          else cur1 += char('a' + k);
        }
        if (cur0.size()) cur0 = '(' + cur0 + '&' + cur1 + ')';
        else cur0 = cur1;
        j = i;
      }
      if (pref.size()) pref = '(' + pref + cur0 + ')' + '|';
      else pref = '(' + cur0 + '|';
//      cout << t << '\n';
//      cout << count(t.begin(), t.end(), '&') + count(t.begin(), t.end(), '|') << ' ' << opt << '\n';
    }
    if (pref.size()) t += ')';
//    cout << count(t.begin(), t.end(), '&') + count(t.begin(), t.end(), '|') << '\n';
    cout << t << '\n';
  }
}

这程序好像有点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
(b&a)
Yes
(a|(b&T))
Yes
T
Yes
((b&a)|(c&(a|(b&T))))
No
Yes
a
Yes
(e&(d&(c&(b&a))))

result:

ok 7 lines, tightest: 5 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: 3712kb

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
(b&a)
No
Yes
a
No
Yes
b
No
Yes
(a|(b&T))
Yes
T

result:

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

Test #4:

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

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: 5 out of 14 (256 test cases)

Test #5:

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

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: 11 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
(d&(c&(b&a)))
Yes
(d&(c&b))
Yes
(d&(c&a))
Yes
(d&(c&(a|(b&T))))
Yes
(d&c)
Yes
(d&(b&a))
Yes
(d&((b&a)|(c&b)))
Yes
(d&((b&a)|(c&a)))
Yes
(d&((b&a)|(c&(a|(b&T)))))
Yes
(d&((b&a)|(c&T)))
Yes
(d&b)
Yes
(d&(b|(c&a)))
Yes
(d&(b|(c&T)))
Yes
(d&a)
Yes
(d&(a|(c&b)))
Yes
(d&(a|(c&T)))
Yes
(d&(a|(b&T...

result:

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

Test #7:

score: 0
Accepted
time: 6ms
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
(e&(d&(c&(b&a))))
Yes
(e&(d&(c&b)))
Yes
(e&(d&(c&a)))
Yes
(e&(d&(c&(a|(b&T)))))
Yes
(e&(d&c))
Yes
(e&(d&(b&a)))
Yes
(e&(d&((b&a)|(c&b))))
Yes
(e&(d&((b&a)|(c&a))))
Yes
(e&(d&((b&a)|(c&(a|(b&T))))))
Yes
(e&(d&((b&a)|(c&T))))
Yes
(e&(d&b))
Yes
(e&(d&(b|(c&a))))
Yes
(e&(d&(b|(c&T))))
Yes
(e&(...

result:

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

Test #8:

score: 0
Accepted
time: 8ms
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&T))
Yes
((b&a)|(c&(a|(b&T))))
Yes
(((b&a)|(c&(a|(b&T))))|(d&((a|(b&T))|(c&T))))
Yes
(((c&(b&a))|(d&((b&a)|(c&(a|(b&T))))))|(e&(((b&a)|(c&(a|(b&T))))|(d&((a|(b&T))|(c&T))))))
Yes
((((a|b)&c)&((d|e)|f))|((((c&(b&a))|(d&(b&a)))|(e&((b&a)|(d&((a|(b&T))|(c&T))))))|(f&(((b&a)|(d&((a|(b&T))...

result:

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

Test #9:

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

input:

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

output:

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

result:

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

Test #10:

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

input:

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

output:

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

result:

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

Test #11:

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

input:

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

output:

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

result:

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

Test #12:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #13:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000100000000000000010000000100010111000000000000000000000000000000000000000...

output:

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

result:

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

Test #14:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #15:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #16:

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

input:

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

output:

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

result:

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

Test #17:

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

input:

65536
7
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
7
00000001000100010001000101110111000100010111011101110111011111110001000101110111011101110111111100010001011101110111011111111111
7
000000010001001100000001001101...

output:

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

result:

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

Test #18:

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

input:

16384
8
0000000000000000000000000000000000000000000000000000000000010001000000000000000000000000000100010000000000010001000100010011011100000000000000000000000000010001000000000001000100010001011101110000000000000001000100010011011100010001000101110011011101111111
8
000101010101011100010101011101110...

output:

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

result:

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

Test #19:

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

input:

4096
9
00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000001000101110000000000000000000000010001011100000...

output:

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

result:

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

Test #20:

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

input:

1024
10
0000000000000000000000000000000100000000000000110000000000000011000000000000000100000000000000110000000000000011000000010000001100000000000000110000000000000011000000000000001100000011000001110000000000000011000000000000001100000011000001110000001100011111000000000000001100000000000000110000...

output:

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

result:

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

Test #21:

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

input:

256
11
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #22:

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

input:

64
12
000101011111111101111111111111110001011111111111011111111111111100010111111111110111111111111111000101111111111101111111111111110001010111111111011111111111111100010111111111110111111111111111000101111111111101111111111111110001011111111111111111111111111101111111111111111111111111111111011111...

output:

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

result:

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

Test #23:

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

input:

16
13
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011000000000000000000000000000000000011111111111111111111111111111100000000000000000000000000000000000000...

output:

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

result:

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

Test #24:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #25:

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

input:

4
14
0000000000000000000000000000000000000000000000000001000100010101000000000000000101010101010101010001010101010101011101110111111100000000000000000000000000000001000000000000000000010101010101010000000100010001010101010101011101010101010101010111111111111111000000000000000000010101010101010000000...

output:

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

result:

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

Test #26:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #27:

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

input:

4
14
0000000000000000000000000001001100000000000000110000000000110011000000000011001100000000001100110000000000110011000000000011001100000000001100110000000000110011000000000011001100000000001100110001001100111111001100111111111100110011111111110011001111111111000000000011001100000011001101110000000...

output:

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

result:

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

Test #28:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #29:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #30:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #31:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #32:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000001100000000000000110000001100111111000000000000000000000000000000000000000...

output:

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

result:

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

Test #33:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #34:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001010100000000000000000000000001010101000000000000000000000000000000000000000...

output:

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

result:

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

Test #35:

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

input:

65536
7
00000000000000010000000100000101000000000001011100000101010111110000000100000001000001110001011100000101001101110011011111111111
7
00000000000000010000000000010111000000000000011100000001011111110000000100000001000000110011011100010101001101110011111111111111
7
000000000000000000000001000100...

output:

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

result:

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

Test #36:

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

input:

1024
10
0000000000000000000000000000000000000000000000000000000000000011000000000000000000000001000001110000000000000111000101010111011100000000000000000000000000000111000000010001011100010011000101110000000100000001000001110001011100000101011111110101111111111111000000000000000100000000000100010000...

output:

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

result:

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

Test #37:

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

input:

64
12
000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000001000101110000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000010000000100010101000101110111111100000000000000000000000000000001000000...

output:

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

result:

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

Test #38:

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

input:

64
12
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000...

output:

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

result:

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

Test #39:

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

input:

64
12
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000...

output:

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

result:

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

Test #40:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000010111000000000000000000000000000000000000000...

output:

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

result:

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

Test #41:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #42:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000100000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #43:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #44:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Extra Test:

score: 0
Extra Test Passed