QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#869542#9980. Boolean Function ReconstructionMax_s_xaMAC ✓398ms4096kbC++173.5kb2025-01-25 10:59:302025-01-25 10:59:30

Judging History

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

  • [2025-01-25 10:59:30]
  • 评测
  • 测评结果:AC
  • 用时:398ms
  • 内存:4096kb
  • [2025-01-25 10:59:30]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <random>
#include <ctime>
#include <chrono>
#include <numeric>
#include <iomanip>
#include <cassert>

typedef long long ll;
typedef double lf;
typedef unsigned long long ull;

// #define DEBUG 1
struct IO
{
    #define MAXSIZE (1 << 20)
    #define isdigit(x) (x >= '0' && x <= '9')
    char buf[MAXSIZE], *p1, *p2;
    char pbuf[MAXSIZE], *pp;
    #if DEBUG
    #else
    IO() : p1(buf), p2(buf), pp(pbuf) {}
    ~IO() {fwrite(pbuf, 1, pp - pbuf, stdout);}
    #endif
    #define gc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin), p1 == p2) ? ' ' : *p1++)
    #define blank(x) (x == ' ' || x == '\n' || x == '\r' || x == '\t')

    template <typename T>
    void Read(T &x)
    {
        #if DEBUG
        std::cin >> x;
        #else
        bool sign = 0; char ch = gc(); x = 0;
        for (; !isdigit(ch); ch = gc())
            if (ch == '-') sign = 1;
        for (; isdigit(ch); ch = gc()) x = x * 10 + (ch ^ 48);
        if (sign) x = -x;
        #endif
    }
    void Read(char *s)
    {
        #if DEBUG
        std::cin >> s;
        #else
        char ch = gc();
        for (; blank(ch); ch = gc());
        for (; !blank(ch); ch = gc()) *s++ = ch;
        *s = 0;
        #endif
    }
    void Read(char &c) {for (c = gc(); blank(c); c = gc());}

    void Push(const char &c)
    {
        #if DEBUG
        putchar(c);
        #else
        if (pp - pbuf == MAXSIZE) fwrite(pbuf, 1, MAXSIZE, stdout), pp = pbuf;
        *pp++ = c;
        #endif
    }
    template <typename T>
    void Write(T x)
    {
        if (x < 0) x = -x, Push('-');
        static T sta[35];
        int top = 0;
        do sta[top++] = x % 10, x /= 10; while (x);
        while (top) Push(sta[--top] ^ 48);
    }
    template <typename T>
    void Write(T x, char lst) {Write(x), Push(lst);}
} IO;
#define Read(x) IO.Read(x)
#define Write(x, y) IO.Write(x, y)
#define Put(x) IO.Push(x)

using namespace std;

const int MAXN = (1 << 15) + 5;

int n;
string val;

bool f[MAXN];

inline string Or(string x, string y)
{
    if (x == "T" || y == "T") return "T";
    if (x == "F") return y;
    if (y == "F") return x;
    return "(" + x + "|" + y + ")";
}
inline string And(string x, string y)
{
    if (x == "F" || y == "F") return "F";
    if (x == "T") return y;
    if (y == "T") return x;
    return "(" + x + "&" + y + ")";
}
string Solve(int u, int l, int r)
{
    string cur = "a"; cur[0] += n - u - 1;
    if (u == n) return f[l] ? "T" : "F";
    int mid = l + r >> 1;
    return Or(Solve(u + 1, l, mid), And(Solve(u + 1, mid, r), cur));
}

int main()
{
    #if DEBUG
    #else
    ios::sync_with_stdio(0), cin.tie(0);
    #endif
    int T;
    cin >> T;
    while (T--)
    {
        cin >> n >> val;
        bool flag = 0;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < (1 << n); j++)
                if (j >> i & 1) flag |= (val[j] == '0' && val[j ^ (1 << i)] == '1');
        if (flag) { cout << "No\n"; continue; }
        for (int i = 0; i < (1 << n); i++)
        {
            if (val[i] == '0') { f[i] = 0; continue; }
            f[i] = 1;
            for (int j = 0; j < n; j++)
                if (i >> j & 1) f[i] &= (val[i ^ (1 << j)] == '0');
        }
        string ans = Solve(0, 0, 1 << n);
        cout << "Yes\n" << ans << "\n";
    }
    return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
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)|((a|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: 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
(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: 12ms
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: 8 out of 18 (65536 test cases)

Test #6:

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

result:

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

Test #7:

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

result:

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

Test #8:

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

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

result:

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

Test #9:

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

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

result:

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

Test #10:

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

result:

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

Test #11:

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

result:

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

Test #12:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #13:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000100000000000000010000000100010111000000000000000000000000000000000000000...

output:

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

result:

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

Test #14:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #15:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #16:

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

input:

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

output:

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

result:

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

Test #17:

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

input:

65536
7
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
7
00000001000100010001000101110111000100010111011101110111011111110001000101110111011101110111111100010001011101110111011111111111
7
000000010001001100000001001101...

output:

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

result:

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

Test #18:

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

input:

16384
8
0000000000000000000000000000000000000000000000000000000000010001000000000000000000000000000100010000000000010001000100010011011100000000000000000000000000010001000000000001000100010001011101110000000000000001000100010011011100010001000101110011011101111111
8
000101010101011100010101011101110...

output:

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

result:

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

Test #19:

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

input:

4096
9
00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000001000101110000000000000000000000010001011100000...

output:

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

result:

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

Test #20:

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

input:

1024
10
0000000000000000000000000000000100000000000000110000000000000011000000000000000100000000000000110000000000000011000000010000001100000000000000110000000000000011000000000000001100000011000001110000000000000011000000000000001100000011000001110000001100011111000000000000001100000000000000110000...

output:

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

result:

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

Test #21:

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

input:

256
11
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #22:

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

input:

64
12
000101011111111101111111111111110001011111111111011111111111111100010111111111110111111111111111000101111111111101111111111111110001010111111111011111111111111100010111111111110111111111111111000101111111111101111111111111110001011111111111111111111111111101111111111111111111111111111111011111...

output:

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

result:

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

Test #23:

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

input:

16
13
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011000000000000000000000000000000000011111111111111111111111111111100000000000000000000000000000000000000...

output:

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

result:

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

Test #24:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #25:

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

input:

4
14
0000000000000000000000000000000000000000000000000001000100010101000000000000000101010101010101010001010101010101011101110111111100000000000000000000000000000001000000000000000000010101010101010000000100010001010101010101011101010101010101010111111111111111000000000000000000010101010101010000000...

output:

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

result:

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

Test #26:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #27:

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

input:

4
14
0000000000000000000000000001001100000000000000110000000000110011000000000011001100000000001100110000000000110011000000000011001100000000001100110000000000110011000000000011001100000000001100110001001100111111001100111111111100110011111111110011001111111111000000000011001100000011001101110000000...

output:

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

result:

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

Test #28:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #29:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #30:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #31:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #32:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000001100000000000000110000001100111111000000000000000000000000000000000000000...

output:

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

result:

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

Test #33:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #34:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001010100000000000000000000000001010101000000000000000000000000000000000000000...

output:

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

result:

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

Test #35:

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

input:

65536
7
00000000000000010000000100000101000000000001011100000101010111110000000100000001000001110001011100000101001101110011011111111111
7
00000000000000010000000000010111000000000000011100000001011111110000000100000001000000110011011100010101001101110011111111111111
7
000000000000000000000001000100...

output:

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

result:

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

Test #36:

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

input:

1024
10
0000000000000000000000000000000000000000000000000000000000000011000000000000000000000001000001110000000000000111000101010111011100000000000000000000000000000111000000010001011100010011000101110000000100000001000001110001011100000101011111110101111111111111000000000000000100000000000100010000...

output:

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

result:

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

Test #37:

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

input:

64
12
000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000001000101110000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000010000000100010101000101110111111100000000000000000000000000000001000000...

output:

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

result:

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

Test #38:

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

input:

64
12
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000...

output:

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

result:

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

Test #39:

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

input:

64
12
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000...

output:

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

result:

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

Test #40:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000010111000000000000000000000000000000000000000...

output:

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

result:

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

Test #41:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #42:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000100000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #43:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #44:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Extra Test:

score: 0
Extra Test Passed