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"
#include <vector>
#include <map>
#define pii pair <int, int>
#define F first
#define S second
#define pb push_back
using namespace std;
vector<int> guess(int n) {
vector <int> ans(n);
ans[0] = ask(1);
map <int, int> ans_pos;
for (int bit = 0; (1 << bit) <= n; ++bit) {
vector <int> pos;
for (int i = 2; i <= n; ++i) {
if ((i >> bit) & 1) pos.pb(i);
}
vector <int> q1 = get_pairwise_xor(pos);
pos.pb(1);
vector <int> q2 = get_pairwise_xor(pos);
map <int, int> cnt;
for (int x : q2) ++cnt[x];
for (int x : q1) --cnt[x];
for (pii p : cnt) {
if (p.F != 0 && p.S != 0) ans_pos[(p.F ^ ans[0])] += (1 << bit);
}
pos.clear();
q1.clear();
q2.clear();
cnt.clear();
}
for (pii p : ans_pos) {
ans[p.S - 1] = p.F;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |