QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#861047#9980. Boolean Function Reconstructionucup-team112#AC ✓872ms4096kbC++2016.6kb2025-01-18 16:00:532025-01-18 16:01:06

Judging History

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

  • [2025-01-18 16:01:06]
  • 评测
  • 测评结果:AC
  • 用时:872ms
  • 内存:4096kb
  • [2025-01-18 16:00:53]
  • 提交

answer

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #define INTERACTIVE

#include <bits/stdc++.h>
using namespace std;

namespace templates {
// type
using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pil = pair<int, ll>;
using Pli = pair<ll, int>;
using Pll = pair<ll, ll>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using qp = priority_queue<T, vector<T>, greater<T>>;
// clang-format off
#define vec(T, A, ...) vector<T> A(__VA_ARGS__);
#define vvec(T, A, h, ...) vector<vector<T>> A(h, vector<T>(__VA_ARGS__));
#define vvvec(T, A, h1, h2, ...) vector<vector<vector<T>>> A(h1, vector<vector<T>>(h2, vector<T>(__VA_ARGS__)));
// clang-format on

// for loop
#define fori1(a) for (ll _ = 0; _ < (a); _++)
#define fori2(i, a) for (ll i = 0; i < (a); i++)
#define fori3(i, a, b) for (ll i = (a); i < (b); i++)
#define fori4(i, a, b, c) for (ll i = (a); ((c) > 0 || i > (b)) && ((c) < 0 || i < (b)); i += (c))
#define overload4(a, b, c, d, e, ...) e
#define fori(...) overload4(__VA_ARGS__, fori4, fori3, fori2, fori1)(__VA_ARGS__)

// declare and input
// clang-format off
#define INT(...) int __VA_ARGS__; inp(__VA_ARGS__);
#define LL(...) ll __VA_ARGS__; inp(__VA_ARGS__);
#define STRING(...) string __VA_ARGS__; inp(__VA_ARGS__);
#define CHAR(...) char __VA_ARGS__; inp(__VA_ARGS__);
#define DOUBLE(...) double __VA_ARGS__; STRING(str___); __VA_ARGS__ = stod(str___);
#define VEC(T, A, n) vector<T> A(n); inp(A);
#define VVEC(T, A, n, m) vector<vector<T>> A(n, vector<T>(m)); inp(A);
// clang-format on

// const value
const ll MOD1   = 1000000007;
const ll MOD9   = 998244353;
const double PI = acos(-1);

// other macro
#if !defined(RIN__LOCAL) && !defined(INTERACTIVE)
#define endl "\n"
#endif
#define spa ' '
#define len(A) ll(A.size())
#define all(A) begin(A), end(A)

// function
vector<char> stoc(string &S) {
    int n = S.size();
    vector<char> ret(n);
    for (int i = 0; i < n; i++) ret[i] = S[i];
    return ret;
}
string ctos(vector<char> &S) {
    int n      = S.size();
    string ret = "";
    for (int i = 0; i < n; i++) ret += S[i];
    return ret;
}

template <class T>
auto min(const T &a) {
    return *min_element(all(a));
}
template <class T>
auto max(const T &a) {
    return *max_element(all(a));
}
template <class T, class S>
auto clamp(T &a, const S &l, const S &r) {
    return (a > r ? r : a < l ? l : a);
}
template <class T, class S>
inline bool chmax(T &a, const S &b) {
    return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
    return (a > b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chclamp(T &a, const S &l, const S &r) {
    auto b = clamp(a, l, r);
    return (a != b ? a = b, 1 : 0);
}

template <typename T>
T sum(vector<T> &A) {
    T tot = 0;
    for (auto a : A) tot += a;
    return tot;
}

template <typename T>
vector<T> compression(vector<T> X) {
    sort(all(X));
    X.erase(unique(all(X)), X.end());
    return X;
}

// input and output
namespace io {
// __int128_t
std::istream &operator>>(std::istream &is, __int128_t &value) {
    std::string str;
    is >> str;
    value    = 0;
    int sign = 1;
    for (size_t i = 0; i < str.size(); i++) {
        if (i == 0 && str[i] == '-') {
            sign = -1;
            continue;
        }
        value = value * 10 + str[i] - '0';
    }
    value *= sign;
    return is;
}

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
    std::ostream::sentry s(dest);
    if (s) {
        __uint128_t tmp = value < 0 ? -value : value;
        char buffer[128];
        char *d = std::end(buffer);
        do {
            --d;
            *d = "0123456789"[tmp % 10];
            tmp /= 10;
        } while (tmp != 0);
        if (value < 0) {
            --d;
            *d = '-';
        }
        int len = std::end(buffer) - d;
        if (dest.rdbuf()->sputn(d, len) != len) {
            dest.setstate(std::ios_base::badbit);
        }
    }
    return dest;
}

// vector<T>
template <typename T>
istream &operator>>(istream &is, vector<T> &A) {
    for (auto &a : A) is >> a;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        os << A[i];
        if (i != A.size() - 1) os << ' ';
    }
    return os;
}

// vector<vector<T>>
template <typename T>
istream &operator>>(istream &is, vector<vector<T>> &A) {
    for (auto &a : A) is >> a;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<vector<T>> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        os << A[i];
        if (i != A.size() - 1) os << endl;
    }
    return os;
}

// pair<S, T>
template <typename S, typename T>
istream &operator>>(istream &is, pair<S, T> &A) {
    is >> A.first >> A.second;
    return is;
}
template <typename S, typename T>
ostream &operator<<(ostream &os, pair<S, T> &A) {
    os << A.first << ' ' << A.second;
    return os;
}

// vector<pair<S, T>>
template <typename S, typename T>
istream &operator>>(istream &is, vector<pair<S, T>> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        is >> A[i];
    }
    return is;
}
template <typename S, typename T>
ostream &operator<<(ostream &os, vector<pair<S, T>> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        os << A[i];
        if (i != A.size() - 1) os << endl;
    }
    return os;
}

// tuple
template <typename T, size_t N>
struct TuplePrint {
    static ostream &print(ostream &os, const T &t) {
        TuplePrint<T, N - 1>::print(os, t);
        os << ' ' << get<N - 1>(t);
        return os;
    }
};
template <typename T>
struct TuplePrint<T, 1> {
    static ostream &print(ostream &os, const T &t) {
        os << get<0>(t);
        return os;
    }
};
template <typename... Args>
ostream &operator<<(ostream &os, const tuple<Args...> &t) {
    TuplePrint<decltype(t), sizeof...(Args)>::print(os, t);
    return os;
}

// io functions
void FLUSH() {
    cout << flush;
}

void print() {
    cout << endl;
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&...tail) {
    cout << head;
    if (sizeof...(Tail)) cout << spa;
    print(std::forward<Tail>(tail)...);
}

template <typename T, typename S>
void prisep(vector<T> &A, S sep) {
    int n = A.size();
    for (int i = 0; i < n; i++) {
        cout << A[i];
        if (i != n - 1) cout << sep;
    }
    cout << endl;
}
template <typename T, typename S>
void priend(T A, S end) {
    cout << A << end;
}
template <typename T>
void prispa(T A) {
    priend(A, spa);
}
template <typename T, typename S>
bool printif(bool f, T A, S B) {
    if (f)
        print(A);
    else
        print(B);
    return f;
}

template <class... T>
void inp(T &...a) {
    (cin >> ... >> a);
}

} // namespace io
using namespace io;

// read graph
vector<vector<int>> read_edges(int n, int m, bool direct = false, int indexed = 1) {
    vector<vector<int>> edges(n, vector<int>());
    for (int i = 0; i < m; i++) {
        INT(u, v);
        u -= indexed;
        v -= indexed;
        edges[u].push_back(v);
        if (!direct) edges[v].push_back(u);
    }
    return edges;
}
vector<vector<int>> read_tree(int n, int indexed = 1) {
    return read_edges(n, n - 1, false, indexed);
}

template <typename T = long long>
vector<vector<pair<int, T>>> read_wedges(int n, int m, bool direct = false, int indexed = 1) {
    vector<vector<pair<int, T>>> edges(n, vector<pair<int, T>>());
    for (int i = 0; i < m; i++) {
        INT(u, v);
        T w;
        inp(w);
        u -= indexed;
        v -= indexed;
        edges[u].push_back({v, w});
        if (!direct) edges[v].push_back({u, w});
    }
    return edges;
}
template <typename T = long long>
vector<vector<pair<int, T>>> read_wtree(int n, int indexed = 1) {
    return read_wedges<T>(n, n - 1, false, indexed);
}

// yes / no
namespace yesno {

// yes
inline bool yes(bool f = true) {
    cout << (f ? "yes" : "no") << endl;
    return f;
}
inline bool Yes(bool f = true) {
    cout << (f ? "Yes" : "No") << endl;
    return f;
}
inline bool YES(bool f = true) {
    cout << (f ? "YES" : "NO") << endl;
    return f;
}

// no
inline bool no(bool f = true) {
    cout << (!f ? "yes" : "no") << endl;
    return f;
}
inline bool No(bool f = true) {
    cout << (!f ? "Yes" : "No") << endl;
    return f;
}
inline bool NO(bool f = true) {
    cout << (!f ? "YES" : "NO") << endl;
    return f;
}

// possible
inline bool possible(bool f = true) {
    cout << (f ? "possible" : "impossible") << endl;
    return f;
}
inline bool Possible(bool f = true) {
    cout << (f ? "Possible" : "Impossible") << endl;
    return f;
}
inline bool POSSIBLE(bool f = true) {
    cout << (f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return f;
}

// impossible
inline bool impossible(bool f = true) {
    cout << (!f ? "possible" : "impossible") << endl;
    return f;
}
inline bool Impossible(bool f = true) {
    cout << (!f ? "Possible" : "Impossible") << endl;
    return f;
}
inline bool IMPOSSIBLE(bool f = true) {
    cout << (!f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return f;
}

// Alice Bob
inline bool Alice(bool f = true) {
    cout << (f ? "Alice" : "Bob") << endl;
    return f;
}
inline bool Bob(bool f = true) {
    cout << (f ? "Bob" : "Alice") << endl;
    return f;
}

// Takahashi Aoki
inline bool Takahashi(bool f = true) {
    cout << (f ? "Takahashi" : "Aoki") << endl;
    return f;
}
inline bool Aoki(bool f = true) {
    cout << (f ? "Aoki" : "Takahashi") << endl;
    return f;
}

} // namespace yesno
using namespace yesno;

} // namespace templates
using namespace templates;

struct RandomNumberGenerator {
    std::mt19937 mt;
    RandomNumberGenerator() : mt(std::chrono::steady_clock::now().time_since_epoch().count()) {}
    RandomNumberGenerator(int seed) : mt(seed) {}

    int operator()(int a, int b) {
        std::uniform_int_distribution<int> dist(a, b - 1);
        return dist(mt);
    }

    int operator()(int b) {
        return (*this)(0, b);
    }

    template <typename T>
    void shuffle(std::vector<T> &v) {
        std::shuffle(v.begin(), v.end(), mt);
    }
};
RandomNumberGenerator rng;

void solve() {
    INT(n);
    STRING(S);
    vec(bool, ok, 1 << n, false);
    fori(bit, 1 << n) {
        ok[bit] = S[bit] == '1';
    }
    fori(bit, 1 << n) {
        fori(i, n) {
            if ((bit >> i) & 1) {
                if (ok[bit ^ (1 << i)] and !(ok[bit])) {
                    No();
                    return;
                }
            }
        }
    }

    Yes();
    if (!ok.back()) {
        print("F");
        return;
    }
    if (ok[0]) {
        print("T");
        return;
    }

    vec(int, idx, n);
    iota(all(idx), 0);

    auto ok_ = ok;
    while (1) {
        rng.shuffle(idx);
        vec(bool, ok, 1 << n, false);
        fori(bit, 1 << n) {
            int nbit = 0;
            fori(i, n) {
                if ((bit >> idx[i]) & 1) {
                    nbit |= 1 << i;
                }
            }
            ok[nbit] = ok_[bit];
        }

        vvec(bool, all_T, n + 1);
        vvec(bool, all_F, n + 1);
        all_T[n] = ok;
        all_F[n] = ok;
        fori(i, 1 << n) {
            all_F[n][i] = !all_F[n][i];
        }
        fori(i, n - 1, -1, -1) {
            all_T[i].resize(1 << i);
            all_F[i].resize(1 << i);
            fori(j, 1 << i) {
                all_T[i][j] = all_T[i + 1][j] & all_T[i + 1][j + (1 << i)];
                all_F[i][j] = all_F[i + 1][j] & all_F[i + 1][j + (1 << i)];
            }
        }

        auto dfs = [&](auto &&self, int i, int bit) -> string {
            if (all_T[i][bit]) return "T";
            if (all_F[i][bit]) return "F";
            string res;
            auto l_ = self(self, i + 1, bit | (1 << i));
            auto r_ = self(self, i + 1, bit);
            if (l_ == "F") {
            } else if (l_ == "T") {
                res += char('a' + idx[i]);
            } else {
                res += "(";
                res += char('a' + idx[i]);
                res += '&';
                res += l_;
                res += ")";
            }
            if (r_ == "F") {
            } else if (r_ == "T") {
                throw;
            } else {
                res = "(" + res;
                res += "|";
                res += r_;
                res += ")";
            }

            return res;
        };

        auto ans = dfs(dfs, 0, 0);

        {
            int cnt = 0;
            for (auto c : ans) {
                if (c == '&' or c == '|') cnt++;
            }
            if (cnt <= ((1 << n - 1)) + 10) {
                print(ans);
                return;
            }
        }
    }
}

int main() {
#ifndef INTERACTIVE
    std::cin.tie(0)->sync_with_stdio(0);
#endif
    // std::cout << std::fixed << std::setprecision(12);
    int t;
    t = 1;
    std::cin >> t;
    while (t--) solve();
    return 0;
}

// // #pragma GCC target("avx2")
// // #pragma GCC optimize("O3")
// // #pragma GCC optimize("unroll-loops")
// // #define INTERACTIVE
//
// #include "kyopro-cpp/template.hpp"
// #include "misc/RandomNumberGenerator.hpp"
// RandomNumberGenerator rng;
//
// void solve() {
//     INT(n);
//     STRING(S);
//     vec(bool, ok, 1 << n, false);
//     fori(bit, 1 << n) {
//         ok[bit] = S[bit] == '1';
//     }
//     fori(bit, 1 << n) {
//         fori(i, n) {
//             if ((bit >> i) & 1) {
//                 if (ok[bit ^ (1 << i)] and !(ok[bit])) {
//                     No();
//                     return;
//                 }
//             }
//         }
//     }
//
//     Yes();
//     if (!ok.back()) {
//         print("F");
//         return;
//     }
//     if (ok[0]) {
//         print("T");
//         return;
//     }
//
//     vec(int, idx, n);
//     iota(all(idx), 0);
//
//     auto ok_ = ok;
//     while (1) {
//         rng.shuffle(idx);
//         vec(bool, ok, 1 << n, false);
//         fori(bit, 1 << n) {
//             int nbit = 0;
//             fori(i, n) {
//                 if ((bit >> idx[i]) & 1) {
//                     nbit |= 1 << i;
//                 }
//             }
//             ok[nbit] = ok_[bit];
//         }
//
//         vvec(bool, all_T, n + 1);
//         vvec(bool, all_F, n + 1);
//         all_T[n] = ok;
//         all_F[n] = ok;
//         fori(i, 1 << n) {
//             all_F[n][i] = !all_F[n][i];
//         }
//         fori(i, n - 1, -1, -1) {
//             all_T[i].resize(1 << i);
//             all_F[i].resize(1 << i);
//             fori(j, 1 << i) {
//                 all_T[i][j] = all_T[i + 1][j] & all_T[i + 1][j + (1 << i)];
//                 all_F[i][j] = all_F[i + 1][j] & all_F[i + 1][j + (1 << i)];
//             }
//         }
//
//         auto dfs = [&](auto &&self, int i, int bit) -> string {
//             if (all_T[i][bit]) return "T";
//             if (all_F[i][bit]) return "F";
//             string res;
//             auto l_ = self(self, i + 1, bit | (1 << i));
//             auto r_ = self(self, i + 1, bit);
//             if (l_ == "F") {
//             } else if (l_ == "T") {
//                 res += char('a' + idx[i]);
//             } else {
//                 res += "(";
//                 res += char('a' + idx[i]);
//                 res += '&';
//                 res += l_;
//                 res += ")";
//             }
//             if (r_ == "F") {
//             } else if (r_ == "T") {
//                 throw;
//             } else {
//                 res = "(" + res;
//                 res += "|";
//                 res += r_;
//                 res += ")";
//             }
//
//             return res;
//         };
//
//         auto ans = dfs(dfs, 0, 0);
//
//         {
//             int cnt = 0;
//             for (auto c : ans) {
//                 if (c == '&' or c == '|') cnt++;
//             }
//             if (cnt <= ((1 << n - 1)) + 10) {
//                 print(ans);
//                 return;
//             }
//         }
//     }
// }
//
// int main() {
// #ifndef INTERACTIVE
//     std::cin.tie(0)->sync_with_stdio(0);
// #endif
//     // std::cout << std::fixed << std::setprecision(12);
//     int t;
//     t = 1;
//     std::cin >> t;
//     while (t--) solve();
//     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
(b&a)
Yes
(b|a)
Yes
T
Yes
((c&(b|a))|(b&a))
No
Yes
a
Yes
(e&(c&(a&(b&d))))

result:

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

Test #2:

score: 0
Accepted
time: 1ms
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: 1ms
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
((b&a)|a)
No
Yes
((a&b)|b)
No
Yes
(b|a)
Yes
T

result:

ok 16 lines, tightest: 2 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: 6 out of 14 (256 test cases)

Test #5:

score: 0
Accepted
time: 16ms
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: 13 out of 18 (65536 test cases)

Test #6:

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

input:

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

output:

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

result:

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

Test #7:

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

result:

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

Test #8:

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

result:

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

Test #9:

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

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

result:

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

Test #10:

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

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

result:

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

Test #11:

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

input:

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

output:

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

result:

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

Test #12:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #13:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000100000000000000010000000100010111000000000000000000000000000000000000000...

output:

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

result:

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

Test #14:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #15:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #16:

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

input:

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

output:

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

result:

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

Test #17:

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

input:

65536
7
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
7
00000001000100010001000101110111000100010111011101110111011111110001000101110111011101110111111100010001011101110111011111111111
7
000000010001001100000001001101...

output:

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

result:

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

Test #18:

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

input:

16384
8
0000000000000000000000000000000000000000000000000000000000010001000000000000000000000000000100010000000000010001000100010011011100000000000000000000000000010001000000000001000100010001011101110000000000000001000100010011011100010001000101110011011101111111
8
000101010101011100010101011101110...

output:

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

result:

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

Test #19:

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

input:

4096
9
00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000001000101110000000000000000000000010001011100000...

output:

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

result:

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

Test #20:

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

input:

1024
10
0000000000000000000000000000000100000000000000110000000000000011000000000000000100000000000000110000000000000011000000010000001100000000000000110000000000000011000000000000001100000011000001110000000000000011000000000000001100000011000001110000001100011111000000000000001100000000000000110000...

output:

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

result:

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

Test #21:

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

input:

256
11
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #22:

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

input:

64
12
000101011111111101111111111111110001011111111111011111111111111100010111111111110111111111111111000101111111111101111111111111110001010111111111011111111111111100010111111111110111111111111111000101111111111101111111111111110001011111111111111111111111111101111111111111111111111111111111011111...

output:

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

result:

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

Test #23:

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

input:

16
13
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011000000000000000000000000000000000011111111111111111111111111111100000000000000000000000000000000000000...

output:

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

result:

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

Test #24:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #25:

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

input:

4
14
0000000000000000000000000000000000000000000000000001000100010101000000000000000101010101010101010001010101010101011101110111111100000000000000000000000000000001000000000000000000010101010101010000000100010001010101010101011101010101010101010111111111111111000000000000000000010101010101010000000...

output:

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

result:

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

Test #26:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #27:

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

input:

4
14
0000000000000000000000000001001100000000000000110000000000110011000000000011001100000000001100110000000000110011000000000011001100000000001100110000000000110011000000000011001100000000001100110001001100111111001100111111111100110011111111110011001111111111000000000011001100000011001101110000000...

output:

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

result:

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

Test #28:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #29:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #30:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #31:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #32:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000001100000000000000110000001100111111000000000000000000000000000000000000000...

output:

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

result:

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

Test #33:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #34:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001010100000000000000000000000001010101000000000000000000000000000000000000000...

output:

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

result:

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

Test #35:

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

input:

65536
7
00000000000000010000000100000101000000000001011100000101010111110000000100000001000001110001011100000101001101110011011111111111
7
00000000000000010000000000010111000000000000011100000001011111110000000100000001000000110011011100010101001101110011111111111111
7
000000000000000000000001000100...

output:

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

result:

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

Test #36:

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

input:

1024
10
0000000000000000000000000000000000000000000000000000000000000011000000000000000000000001000001110000000000000111000101010111011100000000000000000000000000000111000000010001011100010011000101110000000100000001000001110001011100000101011111110101111111111111000000000000000100000000000100010000...

output:

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

result:

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

Test #37:

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

input:

64
12
000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000001000101110000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000010000000100010101000101110111111100000000000000000000000000000001000000...

output:

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

result:

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

Test #38:

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

input:

64
12
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000...

output:

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

result:

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

Test #39:

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

input:

64
12
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000...

output:

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

result:

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

Test #40:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000010111000000000000000000000000000000000000000...

output:

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

result:

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

Test #41:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #42:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000100000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #43:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #44:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Extra Test:

score: 0
Extra Test Passed