Submission #583689

#TimeUsernameProblemLanguageResultExecution timeMemory
583689KoDXoractive (IZhO19_xoractive)C++17
100 / 100
8 ms516 KiB
#include "interactive.h" #include <bits/stdc++.h> using ll = long long; using std::vector; using std::array; using std::pair; using std::tuple; template <class T> constexpr T infty = std::numeric_limits<T>::max() / 2; vector<int> guess(int N) { vector<int> ans(N); ans[0] = ask(1); const auto calc = [&](vector<int> pos) -> std::set<int> { if (pos.empty()) { return {}; } for (auto& x : pos) { x += 1; } std::map<int, int> count; for (const int x : get_pairwise_xor(pos)) { count[x] -= 1; } pos.push_back(1); for (const int x : get_pairwise_xor(pos)) { count[x] += 1; } std::set<int> ret; for (const auto& [x, c] : count) { if (c - (x == 0) > 0) { ret.insert(x ^ ans[0]); } } return ret; }; const int LOG = 7; array<std::set<int>, LOG> set = {}; for (int k = 0; k < LOG; ++k) { vector<int> pos; for (int i = 0; i < N; ++i) { if (i >> k & 1) { pos.push_back(i); } } set[k] = calc(pos); } for (int i = 1; i < N; ++i) { std::set<int> add, del; for (int k = 0; k < LOG; ++k) { if (i >> k & 1) { if (add.empty()) { add = set[k]; } else { std::set<int> next; for (const int x : set[k]) { if (add.find(x) != add.end()) { next.insert(x); } } add = std::move(next); } } else { for (const int x : set[k]) { del.insert(x); } } } for (const int x : del) { add.erase(x); } ans[i] = *add.begin(); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...