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 <bits/stdc++.h>
using namespace std;
vector<int> guess(int n) {
vector <int> ans(n);
ans[0] = ask(1);
map<int, int> ind;
for (int b = 0; (1 << b) < n; ++b) {
vector<int> vec;
for (int i = 0; i < n; ++i) {
if (i >> b & 1) {
vec.push_back(i + 1);
}
}
vector<int> lst = get_pairwise_xor(vec);
map<int, int> cnt;
for (int i : lst) {
cnt[i]++;
}
vec.push_back(1);
cnt[0]--;
vector<int> lst2 = get_pairwise_xor(vec);
for (int i : lst2) {
if (cnt[i] == 0) {
ind[i] |= 1 << b;
} else {
cnt[i]--;
}
}
}
for (auto [element, index] : ind) {
ans[index] = element ^ ans[0];
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |