QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#860895#9980. Boolean Function Reconstructionucup-team159#AC ✓656ms3968kbC++2323.7kb2025-01-18 15:28:552025-01-18 15:29:00

Judging History

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

  • [2025-01-18 15:29:00]
  • 评测
  • 测评结果:AC
  • 用时:656ms
  • 内存:3968kb
  • [2025-01-18 15:28:55]
  • 提交

answer

#line 1 "ucup3-26/F/main.cpp"
#define YOSUPO_AVX2_PRAGMA
// #undef YOSUPO_LOCAL

#line 2 "/home/vscode/yosupo-library/src/yosupo/fastio.hpp"

#include <unistd.h>
#include <algorithm>
#include <array>
#include <bit>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstring>
#include <sstream>
#include <string>
#include <type_traits>
#include <vector>

#line 2 "/home/vscode/yosupo-library/src/yosupo/internal_type_traits.hpp"

#line 5 "/home/vscode/yosupo-library/src/yosupo/internal_type_traits.hpp"

namespace yosupo {

namespace internal {

template <class T>
using is_signed_int128 =
    typename std::conditional<std::is_same<T, __int128_t>::value ||
                                  std::is_same<T, __int128>::value,
                              std::true_type,
                              std::false_type>::type;

template <class T>
using is_unsigned_int128 =
    typename std::conditional<std::is_same<T, __uint128_t>::value ||
                                  std::is_same<T, unsigned __int128>::value,
                              std::true_type,
                              std::false_type>::type;

template <class T>
using make_unsigned_int128 =
    typename std::conditional<std::is_same<T, __int128_t>::value,
                              __uint128_t,
                              unsigned __int128>;

template <class T>
using is_integral =
    typename std::conditional<std::is_integral<T>::value ||
                                  internal::is_signed_int128<T>::value ||
                                  internal::is_unsigned_int128<T>::value,
                              std::true_type,
                              std::false_type>::type;

template <class T>
using is_signed_int = typename std::conditional<(is_integral<T>::value &&
                                                 std::is_signed<T>::value) ||
                                                    is_signed_int128<T>::value,
                                                std::true_type,
                                                std::false_type>::type;

template <class T>
using is_unsigned_int =
    typename std::conditional<(is_integral<T>::value &&
                               std::is_unsigned<T>::value) ||
                                  is_unsigned_int128<T>::value,
                              std::true_type,
                              std::false_type>::type;

template <class T>
using to_unsigned = typename std::conditional<
    is_signed_int128<T>::value,
    make_unsigned_int128<T>,
    typename std::conditional<std::is_signed<T>::value,
                              std::make_unsigned<T>,
                              std::common_type<T>>::type>::type;

template <class T>
using is_integral_t = std::enable_if_t<is_integral<T>::value>;

template <class T>
using is_signed_int_t = std::enable_if_t<is_signed_int<T>::value>;

template <class T>
using is_unsigned_int_t = std::enable_if_t<is_unsigned_int<T>::value>;

template <class T> using to_unsigned_t = typename to_unsigned<T>::type;

}  // namespace internal

}  // namespace yosupo
#line 17 "/home/vscode/yosupo-library/src/yosupo/fastio.hpp"

namespace yosupo {

struct Scanner {
  public:
    Scanner(const Scanner&) = delete;
    Scanner& operator=(const Scanner&) = delete;

    Scanner(FILE* fp) : fd(fileno(fp)) { line[0] = 127; }

    void read() {}
    template <class H, class... T> void read(H& h, T&... t) {
        bool f = read_single(h);
        assert(f);
        read(t...);
    }

    int read_unsafe() { return 0; }
    template <class H, class... T> int read_unsafe(H& h, T&... t) {
        bool f = read_single(h);
        if (!f) return 0;
        return 1 + read_unsafe(t...);
    }

    int close() { return ::close(fd); }

  private:
    static constexpr int SIZE = 1 << 15;

    int fd = -1;
    std::array<char, SIZE + 1> line;
    int st = 0, ed = 0;
    bool eof = false;

    bool read_single(std::string& ref) {
        if (!skip_space()) return false;
        ref = "";
        while (true) {
            char c = top();
            if (c <= ' ') break;
            ref += c;
            st++;
        }
        return true;
    }
    bool read_single(double& ref) {
        std::string s;
        if (!read_single(s)) return false;
        ref = std::stod(s);
        return true;
    }

    template <class T,
              std::enable_if_t<std::is_same<T, char>::value>* = nullptr>
    bool read_single(T& ref) {
        if (!skip_space<50>()) return false;
        ref = top();
        st++;
        return true;
    }

    template <class T,
              internal::is_signed_int_t<T>* = nullptr,
              std::enable_if_t<!std::is_same<T, char>::value>* = nullptr>
    bool read_single(T& sref) {
        using U = internal::to_unsigned_t<T>;
        if (!skip_space<50>()) return false;
        bool neg = false;
        if (line[st] == '-') {
            neg = true;
            st++;
        }
        U ref = 0;
        do {
            ref = 10 * ref + (line[st++] & 0x0f);
        } while (line[st] >= '0');
        sref = neg ? -ref : ref;
        return true;
    }
    template <class U,
              internal::is_unsigned_int_t<U>* = nullptr,
              std::enable_if_t<!std::is_same<U, char>::value>* = nullptr>
    bool read_single(U& ref) {
        if (!skip_space<50>()) return false;
        ref = 0;
        do {
            ref = 10 * ref + (line[st++] & 0x0f);
        } while (line[st] >= '0');
        return true;
    }

    bool reread() {
        if (ed - st >= 50) return true;
        if (st > SIZE / 2) {
            std::memmove(line.data(), line.data() + st, ed - st);
            ed -= st;
            st = 0;
        }
        if (eof) return false;
        auto u = ::read(fd, line.data() + ed, SIZE - ed);
        if (u == 0) {
            eof = true;
            line[ed] = '\0';
            u = 1;
        }
        ed += int(u);
        line[ed] = char(127);
        return true;
    }

    char top() {
        if (st == ed) {
            bool f = reread();
            assert(f);
        }
        return line[st];
    }

    template <int TOKEN_LEN = 0> bool skip_space() {
        while (true) {
            while (line[st] <= ' ') st++;
            if (ed - st > TOKEN_LEN) return true;
            if (st > ed) st = ed;
            for (auto i = st; i < ed; i++) {
                if (line[i] <= ' ') return true;
            }
            if (!reread()) return false;
        }
    }
};

struct Printer {
  public:
    template <char sep = ' ', bool F = false> void write() {}
    template <char sep = ' ', bool F = false, class H, class... T>
    void write(const H& h, const T&... t) {
        if (F) write_single(sep);
        write_single(h);
        write<true>(t...);
    }
    template <char sep = ' ', class... T> void writeln(const T&... t) {
        write<sep>(t...);
        write_single('\n');
    }

    Printer(FILE* _fp) : fd(fileno(_fp)) {}
    ~Printer() { flush(); }

    int close() {
        flush();
        return ::close(fd);
    }

    void flush() {
        if (pos) {
            auto res = ::write(fd, line.data(), pos);
            assert(res != -1);
            pos = 0;
        }
    }

  private:
    static std::array<std::array<char, 2>, 100> small;
    static std::array<unsigned long long, 20> tens;

    static constexpr size_t SIZE = 1 << 15;
    int fd;
    std::array<char, SIZE> line;
    size_t pos = 0;
    std::stringstream ss;

    template <class T,
              std::enable_if_t<std::is_same<char, T>::value>* = nullptr>
    void write_single(const T& val) {
        if (pos == SIZE) flush();
        line[pos++] = val;
    }

    template <class T,
              internal::is_signed_int_t<T>* = nullptr,
              std::enable_if_t<!std::is_same<char, T>::value>* = nullptr>
    void write_single(const T& val) {
        using U = internal::to_unsigned_t<T>;
        if (val == 0) {
            write_single('0');
            return;
        }
        if (pos > SIZE - 50) flush();
        U uval = val;
        if (val < 0) {
            write_single('-');
            uval = -uval;
        }
        write_unsigned(uval);
    }

    template <class U,
              internal::is_unsigned_int_t<U>* = nullptr,
              std::enable_if_t<!std::is_same<char, U>::value>* = nullptr>
    void write_single(U uval) {
        if (uval == 0) {
            write_single('0');
            return;
        }
        if (pos > SIZE - 50) flush();

        write_unsigned(uval);
    }

    static int calc_len(uint64_t x) {
        int i = ((63 - std::countl_zero(x)) * 3 + 3) / 10;
        if (x < tens[i])
            return i;
        else
            return i + 1;
    }

    template <class U,
              internal::is_unsigned_int_t<U>* = nullptr,
              std::enable_if_t<2 >= sizeof(U)>* = nullptr>
    void write_unsigned(U uval) {
        size_t len = calc_len(uval);
        pos += len;

        char* ptr = line.data() + pos;
        while (uval >= 100) {
            ptr -= 2;
            memcpy(ptr, small[uval % 100].data(), 2);
            uval /= 100;
        }
        if (uval >= 10) {
            memcpy(ptr - 2, small[uval].data(), 2);
        } else {
            *(ptr - 1) = char('0' + uval);
        }
    }

    template <class U,
              internal::is_unsigned_int_t<U>* = nullptr,
              std::enable_if_t<4 == sizeof(U)>* = nullptr>
    void write_unsigned(U uval) {
        std::array<char, 8> buf;
        memcpy(buf.data() + 6, small[uval % 100].data(), 2);
        memcpy(buf.data() + 4, small[uval / 100 % 100].data(), 2);
        memcpy(buf.data() + 2, small[uval / 10000 % 100].data(), 2);
        memcpy(buf.data() + 0, small[uval / 1000000 % 100].data(), 2);

        if (uval >= 100000000) {
            if (uval >= 1000000000) {
                memcpy(line.data() + pos, small[uval / 100000000 % 100].data(),
                       2);
                pos += 2;
            } else {
                line[pos] = char('0' + uval / 100000000);
                pos++;
            }
            memcpy(line.data() + pos, buf.data(), 8);
            pos += 8;
        } else {
            size_t len = calc_len(uval);
            memcpy(line.data() + pos, buf.data() + (8 - len), len);
            pos += len;
        }
    }

    template <class U,
              internal::is_unsigned_int_t<U>* = nullptr,
              std::enable_if_t<8 == sizeof(U)>* = nullptr>
    void write_unsigned(U uval) {
        size_t len = calc_len(uval);
        pos += len;

        char* ptr = line.data() + pos;
        while (uval >= 100) {
            ptr -= 2;
            memcpy(ptr, small[uval % 100].data(), 2);
            uval /= 100;
        }
        if (uval >= 10) {
            memcpy(ptr - 2, small[uval].data(), 2);
        } else {
            *(ptr - 1) = char('0' + uval);
        }
    }

    template <
        class U,
        std::enable_if_t<internal::is_unsigned_int128<U>::value>* = nullptr>
    void write_unsigned(U uval) {
        static std::array<char, 50> buf;
        size_t len = 0;
        while (uval > 0) {
            buf[len++] = char((uval % 10) + '0');
            uval /= 10;
        }
        std::reverse(buf.begin(), buf.begin() + len);
        memcpy(line.data() + pos, buf.data(), len);
        pos += len;
    }

    void write_single(const std::string& s) {
        for (char c : s) write_single(c);
    }
    void write_single(const char* s) {
        size_t len = strlen(s);
        for (size_t i = 0; i < len; i++) write_single(s[i]);
    }
    template <class T> void write_single(const std::vector<T>& val) {
        auto n = val.size();
        for (size_t i = 0; i < n; i++) {
            if (i) write_single(' ');
            write_single(val[i]);
        }
    }
};

inline std::array<std::array<char, 2>, 100> Printer::small = [] {
    std::array<std::array<char, 2>, 100> table;
    for (int i = 0; i <= 99; i++) {
        table[i][1] = char('0' + (i % 10));
        table[i][0] = char('0' + (i / 10 % 10));
    }
    return table;
}();
inline std::array<unsigned long long, 20> Printer::tens = [] {
    std::array<unsigned long long, 20> table;
    for (int i = 0; i < 20; i++) {
        table[i] = 1;
        for (int j = 0; j < i; j++) {
            table[i] *= 10;
        }
    }
    return table;
}();

}  // namespace yosupo
#line 2 "/home/vscode/yosupo-library/src/yosupo/random.hpp"

#line 6 "/home/vscode/yosupo-library/src/yosupo/random.hpp"
#include <chrono>
#line 8 "/home/vscode/yosupo-library/src/yosupo/random.hpp"
#include <random>
#line 10 "/home/vscode/yosupo-library/src/yosupo/random.hpp"

namespace yosupo {

struct Xoshiro256StarStar {
  public:
    using result_type = uint64_t;
    Xoshiro256StarStar() : Xoshiro256StarStar(0) {}
    explicit Xoshiro256StarStar(uint64_t seed) {
        // use splitmix64
        // Reference: http://xoshiro.di.unimi.it/splitmix64.c
        for (int i = 0; i < 4; i++) {
            uint64_t z = (seed += 0x9e3779b97f4a7c15);
            z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9;
            z = (z ^ (z >> 27)) * 0x94d049bb133111eb;
            s[i] = z ^ (z >> 31);
        }
    }

    static constexpr result_type min() { return 0; }
    static constexpr result_type max() { return -1; }

    result_type operator()() {
        const uint64_t result_starstar = rotl(s[1] * 5, 7) * 9;

        const uint64_t t = s[1] << 17;

        s[2] ^= s[0];
        s[3] ^= s[1];
        s[1] ^= s[2];
        s[0] ^= s[3];

        s[2] ^= t;

        s[3] = rotl(s[3], 45);

        return result_starstar;
    }

  private:
    // Use xoshiro256**
    // Refereces: http://xoshiro.di.unimi.it/xoshiro256starstar.c
    static uint64_t rotl(const uint64_t x, int k) {
        return (x << k) | (x >> (64 - k));
    }

    std::array<uint64_t, 4> s;
};

// https://github.com/wangyi-fudan/wyhash
struct WYRand {
  public:
    using result_type = uint64_t;
    explicit WYRand(uint64_t seed) : s(seed) {}

    static constexpr result_type min() { return 0; }
    static constexpr result_type max() { return -1; }

    result_type operator()() {
        s += 0x2d358dccaa6c78a5;
        auto x = (unsigned __int128)s * (s ^ 0x8bb84b93962eacc9);
        return (uint64_t)(x ^ (x >> 64));
    }

  private:
    uint64_t s;
};
using Random = WYRand;
inline Random& global_gen() {
    static Random gen(
        std::chrono::steady_clock::now().time_since_epoch().count());
    return gen;
}

template <class G>
concept random_64 = std::uniform_random_bit_generator<G> &&
                    std::same_as<uint64_t, std::invoke_result_t<G&>> &&
                    G::min() == uint64_t(0) && G::max() == uint64_t(-1);

namespace internal {

// random choice from [0, upper]
template <random_64 G> uint64_t uniform_u64(uint64_t upper, G& gen) {
    if (!(upper & (upper + 1))) {
        // b = 00..0011..11
        return gen() & upper;
    }
    int log = 63 - std::countl_zero(upper);
    uint64_t mask = (log == 63) ? ~0ULL : (1ULL << (log + 1)) - 1;
    while (true) {
        uint64_t r = gen() & mask;
        if (r <= upper) return r;
    }
}

// random choice from [0, upper], faster than uniform_u64
template <random_64 G> uint64_t random_u64(uint64_t upper, G& gen) {
    return (uint64_t)(((unsigned __int128)(upper) + 1) * gen() >> 64);
}

}  // namespace internal

template <class T, random_64 G> T uniform(T lower, T upper, G& gen) {
    return T(lower +
             internal::uniform_u64(uint64_t(upper) - uint64_t(lower), gen));
}
template <class T> T uniform(T lower, T upper) {
    return uniform(lower, upper, global_gen());
}
template <class T, random_64 G> T random(T lower, T upper, G& gen) {
    return T(lower +
             internal::random_u64(uint64_t(upper) - uint64_t(lower), gen));
}
template <class T> T random(T lower, T upper) {
    return random(lower, upper, global_gen());
}

template <random_64 G> bool uniform_bool(G& gen) { return gen() & 1; }
inline bool uniform_bool() { return uniform_bool(global_gen()); }

// select 2 elements from [lower, uppper]
template <class T, random_64 G>
std::pair<T, T> uniform_pair(T lower, T upper, G& gen) {
    assert(upper - lower >= 1);
    T a, b;
    do {
        a = uniform(lower, upper, gen);
        b = uniform(lower, upper, gen);
    } while (a == b);
    if (a > b) std::swap(a, b);
    return {a, b};
}
template <class T> std::pair<T, T> uniform_pair(T lower, T upper) {
    return uniform_pair(lower, upper, global_gen());
}

// random value in the interval (0.0, 1.0]
template <class G> inline double open_closed_01(G& gen) {
    union {
        uint64_t i;
        double f;
    } u = {0xbff0000000000000 | (gen() >> 12)};
    return 2.0 + u.f;
}
inline double open_closed_01() {
    return open_closed_01(global_gen());
}

}  // namespace yosupo
#line 6 "ucup3-26/F/main.cpp"
using namespace yosupo;

#line 2 "ucup3-26/F/base.hpp"

#ifdef YOSUPO_AVX2_PRAGMA
#line 5 "ucup3-26/F/base.hpp"
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif

#line 11 "ucup3-26/F/base.hpp"
#include <bitset>
#line 13 "ucup3-26/F/base.hpp"
#include <cmath>
#include <cstdio>
#line 16 "ucup3-26/F/base.hpp"
#include <iostream>
#include <map>
#include <queue>
#include <ranges>
#include <set>
#line 22 "ucup3-26/F/base.hpp"
#include <utility>
#line 24 "ucup3-26/F/base.hpp"

using std::abs, std::pow, std::sqrt;
using std::array, std::vector, std::string, std::queue, std::deque;
using std::countl_zero, std::countl_one, std::countr_zero, std::countr_one;
using std::istream, std::ostream, std::cerr, std::endl;
using std::min, std::max, std::swap;
using std::pair, std::tuple, std::bitset;
using std::popcount;
using std::priority_queue, std::set, std::multiset, std::map;
using std::views::iota, std::views::reverse;

namespace ranges = std::ranges;
using ranges::sort, ranges::copy_n;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef YOSUPO_LOCAL

inline ostream& operator<<(ostream& os, __int128_t x) {
    if (x < 0) {
        os << "-";
        x *= -1;
    }
    if (x == 0) {
        return os << "0";
    }
    string s;
    while (x) {
        s += char(x % 10 + '0');
        x /= 10;
    }
    ranges::reverse(s);
    return os << s;
}
inline ostream& operator<<(ostream& os, __uint128_t x) {
    if (x == 0) {
        return os << "0";
    }
    string s;
    while (x) {
        s += char(x % 10 + '0');
        x /= 10;
    }
    ranges::reverse(s);
    return os << s;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p);
template <class T> ostream& operator<<(ostream& os, const V<T>& v);
template <class T> ostream& operator<<(ostream& os, const deque<T>& v);
template <class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N>& a);
template <class T> ostream& operator<<(ostream& os, const set<T>& s);
template <class T, class U>
ostream& operator<<(ostream& os, const map<T, U>& m);

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    bool f = false;
    for (auto d : v) {
        if (f) os << ", ";
        f = true;
        os << d;
    }
    return os << "]";
}

template <class T> ostream& operator<<(ostream& os, const deque<T>& v) {
    os << "[";
    bool f = false;
    for (auto d : v) {
        if (f) os << ", ";
        f = true;
        os << d;
    }
    return os << "]";
}
template <class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N>& a) {
    os << "[";
    bool f = false;
    for (auto d : a) {
        if (f) os << ", ";
        f = true;
        os << d;
    }
    return os << "]";
}

template <class T> ostream& operator<<(ostream& os, const set<T>& s) {
    os << "{";
    bool f = false;
    for (auto d : s) {
        if (f) os << ", ";
        f = true;
        os << d;
    }
    return os << "}";
}
template <class T> ostream& operator<<(ostream& os, const multiset<T>& s) {
    os << "{";
    bool f = false;
    for (auto d : s) {
        if (f) os << ", ";
        f = true;
        os << d;
    }
    return os << "}";
}

template <class T, class U>
ostream& operator<<(ostream& os, const map<T, U>& s) {
    os << "{";
    bool f = false;
    for (auto p : s) {
        if (f) os << ", ";
        f = true;
        os << p.first << ": " << p.second;
    }
    return os << "}";
}

struct PrettyOS {
    ostream& os;
    bool first;

    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif
#line 9 "ucup3-26/F/main.cpp"

Scanner sc = Scanner(stdin);
Printer pr = Printer(stdout);

void solve() {
    int n;
    sc.read(n);
    string s;
    sc.read(s);

    for (int f : iota(0, 1 << n)) {
        if (s[f] == '0') continue;
        for (int g : iota(0, 1 << n)) {
            if (f & g) continue;
            if (s[f | g] == '0') {
                pr.writeln("No");
                return;
            }
        }
    }

    auto unit = [&](int i) -> string {
        return string(1, char('a' + i));
    };


    V<int> ord(n);    
    auto calc = [&](auto self, int m, uint idx) -> string {
        int x = ord[m];
        uint xf = 1 << x;

        if (m == 0) {
            if (s[idx | (1 << x)] == '0') {
                assert(s[idx] == '0');
                return "F";
            }
            if (s[idx] == '0') {
                return unit(x);
            }
            // 11
            return "T";
        }
        if (m == 1) {
            int y = ord[m - 1];
            uint yf = 1 << y;
            if (s[idx | xf | yf] == '0') {
                assert(s[idx] == '0');
                assert(s[idx | xf] == '0');
                assert(s[idx | yf] == '0');
                // 0000
                return "F";
            }
            // ???1            
            if (s[idx] == '1') {
                // 1111
                assert(s[idx | xf] == '1');
                assert(s[idx | yf] == '1');
                return "T";
            }
            // 0??1

            if (s[idx | xf] == '1' && s[idx | yf] == '0') {
                // 0101
                return unit(x);
            }
            if (s[idx | yf] == '1' && s[idx | xf] == '0') {
                // 0011
                return unit(y);
            }
            if (s[idx | xf] == '1' && s[idx | yf] == '1') {
                // 0111
                return "(" + unit(x) + "|" + unit(y) + ")";
            }
            // 0001
            return "(" + unit(x) + "&" + unit(y) + ")";
        }
        string s0 = self(self, m - 1, idx);
        string s1 = self(self, m - 1, idx | xf);

        if (s1 == "F") {
            s1 = "F";
        } else if (s1 == "T") {
            s1 = unit(x);
        } else {
            s1 = "(" + s1 + "&" + unit(x) + ")";
        }

        if (s0 == "F") {
            return s1;
        } else if (s0 == "T") {
            return "T";
        } else {
            return "(" + s0 + "|" + s1 + ")";
        }
    };

    for (int i : iota(0, n)) {
        ord[i] = i;
    }
    for (int _ : iota(0, 20)) {
        shuffle(ord.begin(), ord.end(), global_gen());
        auto ans = calc(calc, n - 1, 0);
        auto cnt = std::count(ans.begin(), ans.end(), '&') + std::count(ans.begin(), ans.end(), '|');

        if (cnt <= (1 << (n - 1)) + 10) {
            dbg(n, cnt);
            pr.writeln("Yes");
            pr.writeln(ans);
            return;
        }
    }
    assert(false);
}

int main() {
    int t;
    sc.read(t);
    for (int _ : iota(0, t)) {
        solve();
    }
    return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

result:

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

Test #2:

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

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: 3584kb

input:

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

output:

Yes
F
No
No
No
No
No
No
No
Yes
(b&a)
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: 3ms
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: 10 out of 18 (65536 test cases)

Test #6:

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

result:

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

Test #7:

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

result:

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

Test #8:

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

input:

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

output:

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

result:

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

Test #9:

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

result:

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

Test #10:

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

input:

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

output:

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

result:

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

Test #11:

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

input:

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

output:

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

result:

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

Test #12:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000...

output:

Yes
((((((((((((((g&a)&o)&f)&b)&d)&j)&i)|((((((((g&a)&o)&f)&b)&d)&j)|(((((((g&a)&o)&f)&b)&d)|((((((g&a)&o)&f)&b)|(((((g&a)&o)&f)|((((g&a)&o)|(((g&a)|((g|a)&o))&f))&b))&d))&j))&i))&m))|(((((((((g&a)&o)&f)&b)&d)&j)|(((((((g&a)&o)&f)&b)&d)|((((((g&a)&o)&f)&b)|(((((g&a)&o)&f)|((((g&a)&o)|(((g&a)|((g|a)&...

result:

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

Test #13:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000100000000000000010000000100010111000000000000000000000000000000000000000...

output:

Yes
((((((((((((((o&f)&e)&i)&g)&d)&c)|(((((((o&f)&e)&i)&g)&d)|((((((o&f)&e)&i)&g)|(((((o&f)&e)&i)|((((o&f)&e)|(((o&f)|((o|f)&e))&i))&g))&d))&c))&k))|((((((((o&f)&e)&i)&g)&d)|((((((o&f)&e)&i)&g)|(((((o&f)&e)&i)|((((o&f)&e)|(((o&f)|((o|f)&e))&i))&g))&d))&c))|(((((((o&f)&e)&i)&g)|(((((o&f)&e)&i)|((((o&...

result:

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

Test #14:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #15:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #16:

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

input:

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

output:

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

result:

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

Test #17:

score: 0
Accepted
time: 656ms
memory: 3456kb

input:

65536
7
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
7
00000001000100010001000101110111000100010111011101110111011111110001000101110111011101110111111100010001011101110111011111111111
7
000000010001001100000001001101...

output:

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

result:

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

Test #18:

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

input:

16384
8
0000000000000000000000000000000000000000000000000000000000010001000000000000000000000000000100010000000000010001000100010011011100000000000000000000000000010001000000000001000100010001011101110000000000000001000100010011011100010001000101110011011101111111
8
000101010101011100010101011101110...

output:

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

result:

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

Test #19:

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

input:

4096
9
00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000001000101110000000000000000000000010001011100000...

output:

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

result:

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

Test #20:

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

input:

1024
10
0000000000000000000000000000000100000000000000110000000000000011000000000000000100000000000000110000000000000011000000010000001100000000000000110000000000000011000000000000001100000011000001110000000000000011000000000000001100000011000001110000001100011111000000000000001100000000000000110000...

output:

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

result:

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

Test #21:

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

input:

256
11
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #22:

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

input:

64
12
000101011111111101111111111111110001011111111111011111111111111100010111111111110111111111111111000101111111111101111111111111110001010111111111011111111111111100010111111111110111111111111111000101111111111101111111111111110001011111111111111111111111111101111111111111111111111111111111011111...

output:

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

result:

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

Test #23:

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

input:

16
13
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011000000000000000000000000000000000011111111111111111111111111111100000000000000000000000000000000000000...

output:

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

result:

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

Test #24:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes
(((((((((((((m&k)&c)&l)&b)|(((((m&k)&c)&l)&b)&g))|((((((m&k)&c)&l)&b)|(((((m&k)&c)&l)&b)&g))&d))|(((((((m&k)&c)&l)&b)|(((((m&k)|((m&k)&c))&l)&b)&g))|((((((m&k)&c)&l)&b)|(((((m&k)|((m&k)&c))&l)&b)&g))&d))&n))&f)|(((((((((m&k)&c)&l)|((((m&k)|(k&c))&l)&b))|(((((m&k)&c)&l)|((((m&k)|((m|k)&c))&l)&b))...

result:

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

Test #25:

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

input:

4
14
0000000000000000000000000000000000000000000000000001000100010101000000000000000101010101010101010001010101010101011101110111111100000000000000000000000000000001000000000000000000010101010101010000000100010001010101010101011101010101010101010111111111111111000000000000000000010101010101010000000...

output:

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

result:

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

Test #26:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #27:

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

input:

4
14
0000000000000000000000000001001100000000000000110000000000110011000000000011001100000000001100110000000000110011000000000011001100000000001100110000000000110011000000000011001100000000001100110001001100111111001100111111111100110011111111110011001111111111000000000011001100000011001101110000000...

output:

Yes
(((((((((((((j&e)&b)|((e&b)&c))&n)|((((e&b)|(((j|e)&b)&c))&n)&f))|((((((j&e)&b)|((e&b)&c))|((b|(((j&e)|b)&c))&n))|(((((j|e)&b)|(b&c))|(((e|b)|((e|b)&c))&n))&f))&d))|(((((b|(b&c))&n)|(((((j&e)&b)&c)|((b|(b&c))&n))&f))|((((b|(b&c))|n)|(((b|(((j&e)|b)&c))|n)&f))&d))&l))|((((((((j&e)&b)|((e&b)&c))&n...

result:

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

Test #28:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000001000000000000000000000000000000000000000...

output:

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

result:

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

Test #29:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes
((((((((((((((d&o)&a)&g)&i)|(((((d&o)&a)|(((d&o)&a)&g))&i)&j))&n)&f)&e)&c)|((((((((((d&o)&a)&g)&i)&j)&n)&f)&e)|(((((((((d&o)&a)|(((d&o)&a)&g))&i)&j)&n)&f)|((((((((d&o)&a)&g)&i)&j)&n)|(((((((d&o)&a)&g)&i)&j)|((((((d&o)&a)|(((d&o)&a)&g))&i)|(((((d&o)&a)|(((d&o)&a)&g))|((((d&o)&a)|(((d|o)&a)&g))&i)...

result:

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

Test #30:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes
(((((((((((((c&o)&j)&i)&m)|(((((c&o)&j)&i)&m)&a))|((((((c&o)&j)&i)&m)|(((((c&o)&j)&i)&m)&a))&b))|(((((((c&o)&j)&i)&m)|(((((c&o)&j)&i)&m)&a))|((((((c&o)&j)&i)&m)|(((((c&o)&j)&i)&m)&a))&b))&g))&d)|(((((((((c&o)&j)&i)&m)|(((((c&o)&j)&i)&m)&a))|((((((c&o)&j)&i)&m)|(((((c&o)&j)&i)&m)&a))&b))|((((((((...

result:

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

Test #31:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000...

output:

Yes
((((((((((((((k&n)&j)&a)&g)&f)&b)|((((((n&j)&a)&g)|((((n&j)&a)|(((n&j)|(((k&n)|((k|n)&j))&a))&g))&f))&b)&h))&c)|(((((((((k&n)&j)&a)&g)|(((((k&n)&j)&a)|((((k&n)&j)|(((k&n)|(n&j))&a))&g))&f))&b)&h)|((((((((k&n)&j)&a)&g)|(((((k&n)&j)&a)|((((k&n)&j)|(((k&n)|(n&j))&a))&g))&f))&b)|(((((((k&n)&j)&a)&g)...

result:

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

Test #32:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000001100000000000000110000001100111111000000000000000000000000000000000000000...

output:

Yes
((((((((((((((i&c)&e)&a)&h)|(((((i&c)&e)&a)&h)&o))&j)|(((((((i&c)&e)|(((i&c)&e)&a))&h)|(((((i&c)&e)|(((i&c)&e)&a))&h)&o))|((((((i&c)&e)|(((i&c)&e)&a))&h)|(((((i&c)&e)|(((i&c)&e)&a))&h)&o))&j))&m))|((((((((i&c)&e)|(((i&c)&e)&a))&h)|(((((i&c)&e)|(((i&c)&e)&a))&h)&o))|((((((i&c)&e)|(((i&c)&e)&a))&h...

result:

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

Test #33:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

Yes
((((((((((((((m&c)&h)&b)&e)&l)|((((((m&c)&h)&b)&e)|((((m&h)&b)&e)&l))&j))&o)&k)|(((((((((m&c)&h)&b)&e)&l)|((((((m&c)&h)&b)&e)|((((m&h)&b)&e)&l))&j))&o)|((((((((m|c)&h)&b)&e)|(((((m&c)&h)&b)|((((m&c)&h)|(h&b))&e))&l))|((((((m&c)&h)&b)|((((m&c)&h)|(((m|c)&h)&b))&e))|((((m&h)&b)|(((m&h)|(((m&c)|h)&...

result:

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

Test #34:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001010100000000000000000000000001010101000000000000000000000000000000000000000...

output:

Yes
((((((((((((((e&n)&c)|(((e&n)|((e&n)&c))&f))&m)|(((((e&n)|((e&n)&c))|(((e&n)|((e&n)&c))&f))&m)&l))&g)&i)|((((((((e&n)&c)|(((e&n)|((e&n)&c))&f))&m)|(((((e&n)|((e&n)&c))|(((e&n)|((e&n)&c))&f))&m)&l))&g)|(((((((e&n)|((e&n)&c))|(((e&n)|((e&n)&c))&f))&m)|(((((e&n)|((e&n)&c))|(((e&n)|((e&n)&c))&f))&m)...

result:

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

Test #35:

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

input:

65536
7
00000000000000010000000100000101000000000001011100000101010111110000000100000001000001110001011100000101001101110011011111111111
7
00000000000000010000000000010111000000000000011100000001011111110000000100000001000000110011011100010101001101110011111111111111
7
000000000000000000000001000100...

output:

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

result:

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

Test #36:

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

input:

1024
10
0000000000000000000000000000000000000000000000000000000000000011000000000000000000000001000001110000000000000111000101010111011100000000000000000000000000000111000000010001011100010011000101110000000100000001000001110001011100000101011111110101111111111111000000000000000100000000000100010000...

output:

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

result:

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

Test #37:

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

input:

64
12
000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000001000101110000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000010000000100010101000101110111111100000000000000000000000000000001000000...

output:

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

result:

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

Test #38:

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

input:

64
12
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000...

output:

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

result:

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

Test #39:

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

input:

64
12
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000...

output:

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

result:

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

Test #40:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000010111000000000000000000000000000000000000000...

output:

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

result:

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

Test #41:

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

input:

4
14
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000...

output:

Yes
(((((((((((((n&f)&m)&b)&e)&g)&j)&c)|((((((((n&f)&m)&b)&e)|(((((n&f)&m)&b)|((((n&f)&m)|(((n&f)|(f&m))&b))&e))&g))&j)&c)&a))|(((((((((n&f)&m)&b)&e)&g)&j)|(((((((n&f)&m)&b)&e)&g)|((((((n&f)&m)&b)&e)|(((((n&f)&m)&b)&e)&g))&j))&c))|((((((((n&f)&m)&b)&e)&g)|((((((n&f)&m)&b)&e)|(((((n&f)&m)&b)|((((n&f)...

result:

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

Test #42:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000100000001000000000000000000000000000000000000000...

output:

Yes
((((((((((((((j&d)&o)&f)&c)&m)|((((((j&d)&o)&f)&c)|(((((j&d)&o)&f)|((((j&d)|((j&d)&o))&f)&c))&m))&b))&e)|((((((((j&d)&o)&f)|((((j&d)&o)|(((j&d)|((j&d)&o))&f))&c))&m)&b)|(((((((j&d)&o)&f)&c)|(((((j&d)&o)&f)|((((j&d)|((j|d)&o))&f)&c))&m))|((((((j&d)&o)&f)|((((j&d)&o)|(((j&d)|((j|d)&o))&f))&c))|(((...

result:

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

Test #43:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Test #44:

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

input:

1
15
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

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

result:

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

Extra Test:

score: 0
Extra Test Passed