# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
181890 | stefdasca | Xoractive (IZhO19_xoractive) | C++14 | 2 ms | 376 KiB |
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"
using namespace std;
int xorr[12], sol[102];
vector<int> query[12];
int process(vector<int> v)
{
int occ = 1;
int cv = v[0];
int ans = 0;
for(int i = 1; i < v.size(); ++i)
{
if(v[i] == v[i-1])
++occ;
else
{
occ /= 2;
if(occ & 1)
ans ^= cv;
occ = 1;
cv = v[i];
}
}
occ /= 2;
if(occ & 1)
ans ^= cv;
return ans;
}
vector<int> guess(int n)
{
int nr = 1;
for(int i = n; i >= 1; --i)
query[nr].push_back(i);
vector<int> xors = get_pairwise_xor(query[1]);
xorr[nr] = process(xors);
for(int bit = 0; (1<<bit) <= n; ++bit)
{
++nr;
for(int i = n; i >= 1; --i)
if(i & (1<<bit))
query[nr].push_back(i);
xorr[nr] = process(get_pairwise_xor(query[nr]));
}
for(int i = 1; i <= n; ++i)
{
int orr = 0;
for(int j = 2; j <= nr; ++j)
if(!i & (1<<(j-1)))
orr |= xorr[j];
sol[i] = xorr[1] ^ orr;
xorr[1] ^= sol[i];
for(int j = 2; j <= nr; ++j)
if(i & (1<<(j-1)))
xorr[j] ^= sol[i];
}
vector<int>ans;
for(int i = 1; i <= n; ++i)
ans.push_back(sol[i]);
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |