Submission #527822

#TimeUsernameProblemLanguageResultExecution timeMemory
527822definitelynotmeeXoractive (IZhO19_xoractive)C++17
0 / 100
2 ms544 KiB
#include<bits/stdc++.h> #define mp make_pair #define mt make_tuple #define all(x) x.begin(), x.end() #define ff first #define ss second using namespace std; template <typename T> using matrix = vector<vector<T>>; typedef unsigned int uint; typedef unsigned long long ull; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll INFL = (1LL<<62)-1; const int INF = (1<<30)-1; const double EPS = 1e-7; const int MOD = 1e9 + 7; const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count(); const int MAXN = 1e6+1; #include "interactive.h" /*vector<int> arr; int ask(int i){ cout << "ask " << i << endl; int in; cin >> in; return in; } vector<int> get_pairwise_xor(vector<int> q){ /*cout << "get_pairwise_xor "; for(int i : q) cout << i << ' '; cout << endl; vector<int> ret; for(int i = 0; i < q.size(); i++){ for(int j = i; j < q.size(); j++){ ret.push_back(arr[q[i]-1]^arr[q[j]-1]); } } sort(all(ret)); return ret; }*/ vector<int> guess(int n) { int last = ask(n); auto getset =[&](vector<int>& q)->vector<int>{ q.push_back(n); vector<int> tot = get_pairwise_xor(q); q.pop_back(); vector<int> totminus = get_pairwise_xor(q); vector<int> v(q.size()); int p1 = 0, p2 = 0; int ptr = 0; while(p1 < tot.size()){ if(p2 == totminus.size() || totminus[p2] != tot[p1]){ if(tot[p1] != 0){ v[ptr] = tot[p1]^last; ptr++; } } else p2++; p1++; } /*cout << "getset "; for(int i : q) cout << i << ' '; cout << "\n-> "; for(int i : v) cout << i << ' '; cout << endl;*/ return v; }; vector<int> q(n-1); iota(all(q),1); matrix<int> group = {getset(q)}; while(group.size() < n-1){ matrix<int> newgroup; vector<int> q; int ct = 1; for(vector<int>& i : group){ for(int j = 0; j < (i.size()+1)/2; j++) q.push_back(ct), ct++; ct+=i.size()-(i.size()+1)/2; } vector<int> r = getset(q); set<int> s(all(r)); for(vector<int>& i : group){ vector<int> g1, g2; for(int j : i){ if(s.count(j)) g1.push_back(j); else g2.push_back(j); } if(g1.size()) newgroup.push_back(g1); if(g2.size()) newgroup.push_back(g2); } swap(group,newgroup); } vector<int> resp; for(int i = 0 ; i < group.size(); i++){ /*cout << i << ":\n"; for(int j : group[i]) cout << j << ' '; cout << '\n';*/ resp.push_back(group[i].back()); } resp.push_back(last); return resp; } /* int main(){ int n; cin >> n; arr = vector<int>(n); for(int i = 0; i < n; i++){ cin >> arr[i]; } vector<int> resp = guess(n); cout << "! "; for(int i : resp) cout << i << ' '; cout << '\n'; } */

Compilation message (stderr)

Xoractive.cpp:32:3: warning: "/*" within comment [-Wcomment]
   32 |   /*cout << "get_pairwise_xor ";
      |    
Xoractive.cpp: In lambda function:
Xoractive.cpp:60:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |           while(p1 < tot.size()){
      |                 ~~~^~~~~~~~~~~~
Xoractive.cpp:61:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |             if(p2 == totminus.size() || totminus[p2] != tot[p1]){
      |                ~~~^~~~~~~~~~~~~~~~~~
Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:87:28: warning: comparison of integer expressions of different signedness: 'std::vector<std::vector<int>, std::allocator<std::vector<int> > >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   87 |         while(group.size() < n-1){
      |               ~~~~~~~~~~~~~^~~~~
Xoractive.cpp:92:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |             for(int j = 0; j < (i.size()+1)/2; j++)
      |                            ~~^~~~~~~~~~~~~~~~
Xoractive.cpp:114:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int>, std::allocator<std::vector<int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  114 |         for(int i = 0 ; i < group.size(); i++){
      |                         ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...