#include "interactive.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> guess(int n) {
int fir = ask(1);
map<int, int> pos;
vector<int> ans(n); ans[0] = fir;
for (int bit = 0; bit < 7; bit++) {
vector<int> mn;
for (int i = 1; i < n; i++) if ((i >> bit) & 1) mn.push_back(i + 1);
if (!mn.empty()) {
vector<int> xrs = get_pairwise_xor(mn);
mn.push_back(1);
vector<int> new_xrs = get_pairwise_xor(mn);
int id = 0;
for (int u : xrs) {
while (id < new_xrs.size() && new_xrs[id] != u) {
if (new_xrs[id] != 0) {
pos[new_xrs[id] ^ fir] += (1 << bit);
}
id++;
}
id++;
}
while (id < new_xrs.size()) {
if (new_xrs[id] != 0) {
pos[new_xrs[id] ^ fir] += (1 << bit);
}
id++;
}
}
}
for (auto u : pos) ans[u.second / 2] = u.first;
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |