#include "interactive.h"
#include "bits/stdc++.h"
using namespace std;
#ifdef duc_debug
#include "bits/debug.h"
#else
#define debug(...)
#endif
const int LG = 6;
void remove_overlap(vector<int> &x, vector<int> &y) {
multiset<int> s(x.begin(), x.end());
for(auto &i:y) s.erase(s.find(i));
x.clear();
for(auto &i:s) x.push_back(i);
}
map<int, int> mp;
vector<int> guess(int n) {
vector<int> a(n);
a[0] = ask(1);
for(int i = 0; i <= LG; ++i) {
vector<int> t;
for(int mask = 1; mask < n; ++mask) {
if(mask >> i & 1) {
t.push_back(mask + 1);
}
}
if(t.empty()) continue;
vector<int> y = get_pairwise_xor(t);
t.push_back(1);
vector<int> x = get_pairwise_xor(t);
remove_overlap(x, y);
x.erase(x.begin());
x.erase(unique(x.begin(), x.end()), x.end());
for(auto &v:x) {
v ^= a[0];
}
for(auto &v:x) {
mp[v] |= (1 << i);
}
}
for(auto i:mp) {
a[i.second] = i.first;
}
debug(a);
return a;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |