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> ans;
void reduce(vector<int>& v, int sz) {
vector<int> cur = {};
sort(v.begin(), v.end());
for (int i = sz; i < (int)v.size(); i += 2) cur.push_back(v[i]);
swap(cur, v);
}
vector<int> get_values(vector<int> pos) {
vector<int> with = pos;
with.push_back(1);
sort(with.begin(), with.end());
vector<int> xr_with = get_pairwise_xor(with);
vector<int> xr_without = get_pairwise_xor(pos);
reduce(xr_with, with.size());
reduce(xr_without, pos.size());
vector<int> vals = {};
for (int val : xr_without) {
for (int i = 0; i < (int)xr_with.size(); ++i) {
if (xr_with[i] == val) {
xr_with.erase(xr_with.begin() + i);
break;
}
}
}
for (int val : xr_with) {
vals.push_back(val ^ ans[0]);
}
return vals;
}
vector<int> guess(int n) {
map<int, int> mp;
ans.resize(n);
ans[0] = ask(1);
for (int i = 0; i < 7; ++i) {
vector<int> cur;
for (int j = 2; j <= n; ++j) {
if (j & 1 << i) cur.push_back(j);
}
if (cur.empty()) continue;
vector<int> v = get_values(cur);
for (int val : v) {
mp[val] += 1 << i;
}
}
for (pair<int, int> p : mp) {
ans[p.second - 1] = p.first;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |