QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#863712#9980. Boolean Function ReconstructionpyimingAC ✓465ms3968kbC++141.8kb2025-01-19 21:33:462025-01-19 21:33:47

Judging History

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

  • [2025-01-19 21:33:47]
  • 评测
  • 测评结果:AC
  • 用时:465ms
  • 内存:3968kb
  • [2025-01-19 21:33:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n;
string s;
bool check(){
    for(int i=0;i<(1<<n);i++) if(s[i]=='0'){
        for(int j=i;j;j=(j-1)&i) if(s[((j-1)&i)]=='1'){
            return false;
        }
    }
    return true;
}
string solve(int now,vector<int> &t){
    if(now==n){
        return "T";
    }
    vector<int> t0,t1;
    for(int i:t){
        if(i&(1<<now)){
            t1.push_back(i);
        }
        else{
            t0.push_back(i);
        }
    }
    t.clear();
    string temp;
    temp=char('a'+now);
    if(t0.size()&&t1.size()){
        string s1=solve(now+1,t0);
        string s2=solve(now+1,t1);
        if(s2=="T"){
            s2=temp;
        }
        else{
            s2="("+temp+"&"+s2+")";
        }
        if(s1!="T"){
            s1="("+s1+"|"+s2+")";
        }
        return s1;
    }
    if(t0.size()){
        return solve(now+1,t0);
    }
    if(t1.size()){
        string s=solve(now+1,t1);
        if(s=="T"){
            return temp;
        }
        else{
            return "("+temp+"&"+s+")";
        }
    }
    return {};
}
int main(){
    cin.tie(0)->sync_with_stdio(0);
    int T;
    cin>>T;
    while(T--){
        cin>>n>>s;
        if(!check()){
            cout<<"No\n";
            continue;
        }
        cout<<"Yes\n";
        vector<int> t;
        for(int i=0;i<(1<<n);i++) if(s[i]=='1'){
            bool flag=1;
            for(int j=i;j;j=(j-1)&i) if(s[((j-1)&i)]=='1'){
                flag=0;
                break;
            }
            if(flag){
                t.push_back(i);
            }
        }
        if(t.empty()){
            cout<<"F";
        }
        else{
            cout<<solve(0,t);
        }
        cout<<"\n";
    }
    return 0;
}

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

詳細信息

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

result:

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

Test #4:

score: 0
Accepted
time: 1ms
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: 6ms
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: 1ms
memory: 3584kb

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

result:

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

Test #7:

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

result:

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

Test #8:

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

input:

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

output:

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

result:

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

Test #9:

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

result:

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

Test #10:

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

result:

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

Test #11:

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

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
((b&(c&(d&e)))|(a&((c&(d&e))|(b&((d&e)|(c&(e|d)))))))
Yes
((b&(c&(d&(e&f))))|(a&((c&(d&(e&f)))|(b&((d&(e&f))|(c&((e&f)|(d&(f|e)))))))))
Yes
(((c&(d&(e&(f&g))))|(b&((d&(e&(f&g)))|(c&((e&(f&g))|(d&((f&g)|(e&(g|f)))))))))|(a&(((d&(e&(f&g)))|(c&((e&(f&g))|...

result:

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

Test #12:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000...

output:

Yes
((((((((h&(i&(j&(k&(l&(m&(n&o)))))))|(g&((i&(j&(k&(l&(m&(n&o))))))|(h&((j&(k&(l&(m&(n&o)))))|(i&((k&(l&(m&(n&o))))|(j&((l&(m&(n&o)))|(k&((m&(n&o))|(l&((n&o)|(m&(o|n)))))))))))))))|(f&(((i&(j&(k&(l&(m&(n&o))))))|(h&((j&(k&(l&(m&(n&o)))))|(i&((k&(l&(m&(n&o))))|(j&((l&(m&(n&o)))|(k&((m&(n&o))|(l&((...

result:

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

Test #13:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000100000000000000010000000100010111000000000000000000000000000000000000000...

output:

Yes
(((((((((i&(j&(k&(l&(m&(n&o))))))|(h&((j&(k&(l&(m&(n&o)))))|(i&((k&(l&(m&(n&o))))|(j&((l&(m&(n&o)))|(k&((m&(n&o))|(l&((n&o)|(m&(o|n)))))))))))))|(g&(((j&(k&(l&(m&(n&o)))))|(i&((k&(l&(m&(n&o))))|(j&((l&(m&(n&o)))|(k&((m&(n&o))|(l&((n&o)|(m&(o|n)))))))))))|(h&(((k&(l&(m&(n&o))))|(j&((l&(m&(n&o)))|...

result:

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

Test #14:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #15:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #16:

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

input:

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

output:

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

result:

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

Test #17:

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

input:

65536
7
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
7
00000001000100010001000101110111000100010111011101110111011111110001000101110111011101110111111100010001011101110111011111111111
7
000000010001001100000001001101...

output:

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

result:

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

Test #18:

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

input:

16384
8
0000000000000000000000000000000000000000000000000000000000010001000000000000000000000000000100010000000000010001000100010011011100000000000000000000000000010001000000000001000100010001011101110000000000000001000100010011011100010001000101110011011101111111
8
000101010101011100010101011101110...

output:

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

result:

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

Test #19:

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

input:

4096
9
00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000001000101110000000000000000000000010001011100000...

output:

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

result:

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

Test #20:

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

input:

1024
10
0000000000000000000000000000000100000000000000110000000000000011000000000000000100000000000000110000000000000011000000010000001100000000000000110000000000000011000000000000001100000011000001110000000000000011000000000000001100000011000001110000001100011111000000000000001100000000000000110000...

output:

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

result:

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

Test #21:

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

input:

256
11
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #22:

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

input:

64
12
000101011111111101111111111111110001011111111111011111111111111100010111111111110111111111111111000101111111111101111111111111110001010111111111011111111111111100010111111111110111111111111111000101111111111101111111111111110001011111111111111111111111111101111111111111111111111111111111011111...

output:

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

result:

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

Test #23:

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

input:

16
13
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011000000000000000000000000000000000011111111111111111111111111111100000000000000000000000000000000000000...

output:

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

result:

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

Test #24:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #25:

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

input:

4
14
0000000000000000000000000000000000000000000000000001000100010101000000000000000101010101010101010001010101010101011101110111111100000000000000000000000000000001000000000000000000010101010101010000000100010001010101010101011101010101010101010111111111111111000000000000000000010101010101010000000...

output:

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

result:

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

Test #26:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #27:

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

input:

4
14
0000000000000000000000000001001100000000000000110000000000110011000000000011001100000000001100110000000000110011000000000011001100000000001100110000000000110011000000000011001100000000001100110001001100111111001100111111111100110011111111110011001111111111000000000011001100000011001101110000000...

output:

Yes
((((((((((j&(k&(l&(m&n))))|(i&(((l&n)|(k&((m&n)|(l&m))))|(j&((m&n)|(k&n))))))|(h&((((l&(m&n))|(k&(l&n)))|(j&((l&n)|(k&(m&n)))))|(i&((n|l)|(j&(k&m)))))))|(g&(((((l&(m&n))|(k&(l&n)))|(j&(l&n)))|(i&(((n|(l&m))|(k&l))|(j&l))))|(h&(((((m&n)|(l&n))|(k&(n|(l&m))))|(j&((l&m)|(k&l))))|(i&(m|k)))))))|(f&(...

result:

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

Test #28:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #29:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #30:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes
((((((((h&((j&(l&(m&(n&o))))|(i&((k&(l&(m&(n&o))))|(j&((m&(n&o))|(l&((n&o)|(m&o)))))))))|(g&(h&(i&((l&(m&(n&o)))|(j&(m&o)))))))|(f&(((i&(j&(l&(m&(n&o)))))|(h&((j&((m&(n&o))|(l&(m&o))))|(i&((l&(m&(n&o)))|(j&(((n&o)|(m&o))|(l&(o|(m&n))))))))))|(g&(h&((j&(k&(l&(n&o))))|(i&((m&(n&o))|(l&(m&o))))))))...

result:

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

Test #31:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #32:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000001100000000000000110000001100111111000000000000000000000000000000000000000...

output:

Yes
((((((((h&(i&((k&(l&(m&n)))|(j&(k&((m&n)|(l&n)))))))|(g&((i&(j&(k&(l&(m&n)))))|(h&((j&(k&(l&(m&n))))|(i&(((l&(m&n))|(k&((m&n)|(l&(n|m)))))|(j&((l&(n&o))|(k&n))))))))))|(f&(((i&(j&(k&(l&(m&n)))))|(h&((j&(k&(l&(m&n))))|(i&(((l&(m&n))|(k&((m&n)|(l&(n|m)))))|(j&((l&(n&o))|(k&n))))))))|(g&((i&((k&(l&...

result:

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

Test #33:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #34:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001010100000000000000000000000001010101000000000000000000000000000000000000000...

output:

Yes
(((((((((i&(j&(k&(m&n))))|(h&(((k&(m&(n&o)))|(j&(k&((m&n)|(l&(n&o))))))|(i&((k&((m&n)|(l&(n&o))))|(j&((m&n)|(k&(n|m)))))))))|(g&(((j&(k&((m&(n&o))|(l&(m&n)))))|(i&((k&(m&n))|(j&((l&(m&(n&o)))|(k&((n&o)|(l&n))))))))|(h&(((k&((m&n)|(l&(n&o))))|(j&(((m&(n&o))|(l&(m&n)))|(k&((n|(m&o))|(l&m))))))|(i&...

result:

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

Test #35:

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

input:

65536
7
00000000000000010000000100000101000000000001011100000101010111110000000100000001000001110001011100000101001101110011011111111111
7
00000000000000010000000000010111000000000000011100000001011111110000000100000001000000110011011100010101001101110011111111111111
7
000000000000000000000001000100...

output:

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

result:

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

Test #36:

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

input:

1024
10
0000000000000000000000000000000000000000000000000000000000000011000000000000000000000001000001110000000000000111000101010111011100000000000000000000000000000111000000010001011100010011000101110000000100000001000001110001011100000101011111110101111111111111000000000000000100000000000100010000...

output:

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

result:

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

Test #37:

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

input:

64
12
000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000001000101110000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000010000000100010101000101110111111100000000000000000000000000000001000000...

output:

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

result:

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

Test #38:

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

input:

64
12
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000...

output:

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

result:

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

Test #39:

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

input:

64
12
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000...

output:

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

result:

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

Test #40:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000010111000000000000000000000000000000000000000...

output:

Yes
((((((((h&(i&(j&(k&(l&(m&n))))))|(g&(h&((j&(k&(l&(m&n))))|(i&(j&((l&(m&n))|(k&((m&n)|(l&m))))))))))|(f&((h&((j&(k&(l&(m&n))))|(i&((k&(l&(m&n)))|(j&((l&(m&n))|(k&(l&m))))))))|(g&(((j&(k&(l&(m&n))))|(i&(j&((l&(m&n))|(k&(l&n))))))|(h&((j&((l&(m&n))|(k&(m&n))))|(i&((k&(m&n))|(j&(((m&n)|(l&(n|m)))|(k...

result:

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

Test #41:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #42:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000100000001000000000000000000000000000000000000000...

output:

Yes
((((((((h&(i&(j&((l&(m&(n&o)))|(k&((m&(n&o))|(l&(m&(o|n)))))))))|(g&(((j&(k&(l&(m&(n&o)))))|(i&((k&(l&(m&(n&o))))|(j&(k&((m&(n&o))|(l&(m&(o|n)))))))))|(h&((j&((l&(m&(n&o)))|(k&(l&(m&o)))))|(i&((k&((m&(n&o))|(l&(m&n))))|(j&((m&(n&o))|(k&(((n&o)|(m&(o|n)))|(l&(o|m)))))))))))))|(f&(((i&(j&(k&(l&((n...

result:

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

Test #43:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes
((((((((h&(i&(j&(k&(l&(m&(n&o)))))))|(g&((i&(j&(k&(l&(m&(n&o))))))|(h&((j&(k&(l&(m&(n&o)))))|(i&((k&(l&(m&(n&o))))|(j&(k&(l&(m&(o|n))))))))))))|(f&(((i&(j&(k&(l&(m&(n&o))))))|(h&((j&(k&(l&(m&(n&o)))))|(i&((k&(l&(m&(n&o))))|(j&((l&(m&(n&o)))|(k&(l&((n&o)|(m&n)))))))))))|(g&(((j&(k&(l&(m&(n&o)))))...

result:

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

Test #44:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Extra Test:

score: 0
Extra Test Passed