# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
342103 | spike1236 | Xoractive (IZhO19_xoractive) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <interactive.h>
using namespace std;
#define veci vector <int>
#define pb push_back
#define f first
#define s second
veci guess(int n) {
veci ans(n);
ans[0] = ask(1);
map <int, int> idx;
for(int bit = 0; bit < __lg(n); ++bit) {
veci cur;
for(int i = 2; i <= n; ++i) if((i >> bit) & 1) cur.pb(i);
if(cur.empty()) continue;
veci with1 = cur;
with1.pb(1);
with1 = get_pairwise_xor(with1);
cur = get_pairwise_xor(cur);
multiset <int> st;
for(auto it : with1) st.insert(it);
for(auto it : cur) st.erase(st.find(it));
for(auto it : st) idx[it ^ ans[0]] |= (1 << bit);
}
for(auto it : idx) ans[it.s - 1] = it.f;
for(int i = 0; i < n; ++i) if(!ans[i]) ans[i] = ask(i + 1);
return ans;
}