# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
218850 | 2020-04-02T20:16:54 Z | Lawliet | Xoractive (IZhO19_xoractive) | C++14 | 10 ms | 384 KB |
#include "interactive.h" #include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; const int MAXN = 110; int N; int v[MAXN]; /*int ask(int i) { return v[i]; } vector<int> get_pairwise_xor(vector<int> a) { vector< int > ans; for(int i = 0 ; i < a.size() ; i++) for(int j = 0 ; j < a.size() ; j++) ans.push_back( v[i]^v[j] ); sort( ans.begin() , ans.end() ); return ans; }*/ vector< int > guess(int n) { vector< int > ans; if( n <= 15 ) { for (int i = 1; i <= n; i++) ans.push_back( ask(i) ); return ans; } int k = 4; ans.push_back( ask( 1 ) ); int last = 0; while( last < n ) { vector< int > query; for(int i = last ; i < last + k && i < n ; i++) query.push_back( i + 1 ); int qtdNumbers = query.size(); vector< int > aux = get_pairwise_xor( query ); vector< int > answerQuery; for(int i = qtdNumbers ; i < aux.size() ; i += 2) answerQuery.push_back( aux[i] ); vector< pii > allPairs; for(int i = 0 ; i < qtdNumbers ; i++) for(int j = i + 1 ; j < qtdNumbers ; j++) allPairs.push_back( { i , j } ); do { vector< int > values( qtdNumbers , 0 ); values[0] = ans[last]; for(int i = 0 ; i < allPairs.size() ; i++) { if( allPairs[i].first != 0 ) continue; int curInd = allPairs[i].second; values[curInd] = aux[i]^values[0]; } vector< int > allXor; for(int i = 0 ; i < qtdNumbers ; i++) for(int j = i + 1 ; j < qtdNumbers ; j++) allXor.push_back( values[i]^values[j] ); sort( allXor.begin() , allXor.end() ); if( allXor == answerQuery ) { for(int i = 1 ; i < qtdNumbers ; i++) ans.push_back( values[i] ); break; } } while( next_permutation( allPairs.begin() , allPairs.end() )); last = last + k; } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 4 ms | 256 KB | Output is correct |
4 | Correct | 4 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 384 KB | Output is not correct |
2 | Halted | 0 ms | 0 KB | - |