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> res[7], v, p, q, t;
vector<int> guess(int n)
{
int x=ask(1);
for (int i=0; i<=6; i++)
{
t.clear();
for (int j=2; j<=n; j++)
if (j&(1<<i))
t.push_back(j);
if (t.empty())
p.clear();
else
p=get_pairwise_xor(t);
t.push_back(1);
q=get_pairwise_xor(t);
for (int u:p)
q.erase(find(q.begin(), q.end(), u));
for (int j=1; j<q.size(); j+=2)
{
v.push_back(q[j]^x);
res[i].push_back(q[j]^x);
}
}
sort(v.begin(), v.end());
v.resize(unique(v.begin(), v.end())-v.begin());
vector<int> ans(n);
ans[0]=x;
for (int u:v)
{
int ind=0;
for (int i=0; i<=6; i++)
if (find(res[i].begin(), res[i].end(), u)!=res[i].end())
ind|=1<<i;
ans[ind-1]=u;
}
return ans;
}
Compilation message (stderr)
Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:22:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | for (int j=1; j<q.size(); j+=2)
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |