#include #include #include using namespace std; class xrand { uint64_t x; public: using result_type = uint32_t; static constexpr result_type min() { return numeric_limits::min(); } static constexpr result_type max() { return numeric_limits::max(); } xrand(uint64_t k) : x(k) {} xrand() : xrand(1) {} result_type operator()() { x ^= x << 9; x ^= x >> 7; return (x * 0x123456789abcdef) >> 32; } }; constexpr int n = 256, len = 2048; uint32_t a[len], b[len], c[len], a1[len], b1[len], c1[len]; xrand rng; uniform_int_distribution dist(0, n - 1); int calc_score(const bitset &s) { for (int i = 0; i < len; i++) { if (s[a[i]] != a1[i] and s[b[i]] != b1[i] and s[c[i]] != c1[i]) { return i; } } return len; } int main() { const clock_t start = clock(); for (int i = 0; i < len; i++) { cin >> a[i] >> b[i] >> c[i] >> a1[i] >> b1[i] >> c1[i]; } bitset best, s; int best_score = calc_score(best); while (true) { const double phase = (clock() - start) / (1.9 * CLOCKS_PER_SEC); if (phase >= 1) break; for (int i = 0; i < 100; i++) { const int idx = dist(rng); s.flip(idx); const int score = calc_score(s); if (score < best_score) { s.flip(idx); } else if (score > best_score) { best_score = score; best = s; } } } cout << best << endl; return 0; }