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 <bits/stdc++.h>
#include "interactive.h"
using namespace std;
vector<int> query(vector<int>& v) {
if (v.empty()) return vector<int> {};
return get_pairwise_xor(v);
}
vector<int> guess(int n) {
vector<int> disc, ans(n, 0);
vector<set<int>> layer(7);
int a0 = ask(1);
for (int i = 0; i <= 6; i++) {
vector<int> s, a, b;
for (int j = 2; j <= n; j++) {
if (j & (1 << i)) s.push_back(j);
}
a = query(s);
s.push_back(1);
b = query(s);
for (int x : a) {
for (int j = 0; j < (int) b.size(); j++) {
if (b[j] == x) {
b.erase(b.begin() + j);
break;
}
}
}
for (int x : b) {
disc.push_back(x ^ a0);
layer[i].insert(x ^ a0);
}
}
sort(disc.begin(), disc.end());
disc.erase(unique(disc.begin(), disc.end()), disc.end());
ans[0] = a0;
for (int x : disc) {
if (x == a0) continue;
int pos = 0;
for (int i = 0; i <= 6; i++) if (layer[i].count(x)) pos += (1 << i);
ans[pos - 1] = x;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |