# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
218854 | Lawliet | Xoractive (IZhO19_xoractive) | C++14 | 6 ms | 384 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"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int MAXN = 110;
int N;
int v[MAXN];
map< int , int > valuesBlock[MAXN];
vector<int> compress(vector<int> a)
{
int sz = a.size();
int r = sqrt( sz );
vector<int> ans;
for(int i = r ; i < sz ; i += 2)
ans.push_back( a[i] );
return ans;
}
vector<int> queryXor(vector<int> a)
{
vector<int> ans = get_pairwise_xor( a );
compress( ans );
return ans;
}
vector<int> queryIntersection(vector<int> a, vector<int> b)
{
vector< int > ans;
vector< int > query;
for(int i = 0 ; i < a.size() ; i++)
query.push_back( a[i] );
vector< int > answerWithout = queryXor( query );
for(int i = 0 ; i < b.size() ; i++)
query.push_back( b[i] );
vector< int > answerWith = queryXor( query );
int p = 0;
for(int j = 0 ; j < answerWith.size() ; j++)
{
if( answerWith[j] == answerWithout[p] ) p++;
else ans.push_back( answerWith[j] );
}
return ans;
}
vector< int > guess(int n)
{
vector< int > ans( n , 0 );
int szBlock = 9;
int qtdBlocks = (n - 1)/szBlock;
if( n <= 15 )
{
for (int i = 1; i <= n; i++)
ans[i - 1] = ask(i);
return ans;
}
ans[0] = ask(1);
for(int i = 0 ; i <= qtdBlocks ; i++)
{
vector< int > A;
vector< int > B;
for(int j = i*szBlock ; j < n && j/szBlock == i ; j++)
if( j != 0 ) A.push_back( j + 1 );
B.push_back( 1 );
vector< int > cur = queryIntersection( A , B );
for(int j = 0 ; j < cur.size() ; j++)
valuesBlock[i][ cur[j]^ans[0] ] = 1;
}
for(int i = 0 ; i < szBlock ; i++)
{
vector< int > A;
vector< int > B;
for(int j = i ; j < n ; j += szBlock)
if( j != 0 ) A.push_back( j + 1 );
B.push_back( 1 );
vector< int > cur = queryIntersection( A , B );
for(int j = 0 ; j < cur.size() ; j++)
{
int curValue = cur[j]^ans[0];
for(int t = 0 ; t <= qtdBlocks ; t++)
if( valuesBlock[t][curValue] == 1 ) ans[ t*szBlock + i ] = curValue;
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |