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>
using namespace std;
#include "interactive.h"
// ask(i) := returns value at i
// get_pairwise_xor(vec) := returns a set of pairwise xor's
map<int, int> loc;
vector<int> guess(int n){
int lst = ask(n);
for(int bt = 0; bt < 7; bt++){
vector<int> vec;
for(int i = 1; i <= n - 1; i++)
if(i & (1 << bt)) vec.push_back(i);
vector<int> st, fn;
{
if(vec.empty()) st = {};
else st = get_pairwise_xor(vec);
}
{
vec.push_back(n);
fn = get_pairwise_xor(vec);
}
vector<int> vals;
int a = 0, b = 0;
for(; a < (int) st.size(); a++, b++)
while(b < (int) fn.size() && fn[b] != st[a]) vals.push_back(fn[b++]);
while(b < (int) fn.size()) vals.push_back(fn[b++]);
for(int j = 1; j < (int) vals.size(); j += 2)
loc[vals[j] ^ lst] ^= 1 << bt;
}
vector<int> ans;
ans.resize(n, 0);
for(auto x : loc) ans[x.second - 1] = x.first;
ans[n - 1] = lst;
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |