Submission #339086

#TimeUsernameProblemLanguageResultExecution timeMemory
339086nandonathanielXoractive (IZhO19_xoractive)C++14
100 / 100
6 ms620 KiB
#include "interactive.h" #include "bits/stdc++.h" using namespace std; int arr[105]; map<int,int> balik; vector<int> kurang(vector<int> a,vector<int> b){ map<int,int> byka,bykb; vector<int> ret; for(auto isi : a)byka[isi]++; for(auto isi : b)bykb[isi]++; for(map<int,int>::iterator it=byka.begin();it!=byka.end();++it){ if(it->first==0)continue; int cnt=it->second-bykb[it->first]; for(int i=1;i<=cnt/2;i++)ret.push_back(it->first); } return ret; } vector<int> guess(int n) { vector <int> ans; int satu=ask(1); arr[1]=satu; for(int i=0;i<7;i++){ vector<int> v; for(int j=2;j<=n;j++){ if((1<<i) & j){ v.push_back(j); } } if(v.empty())continue; vector<int> kecil=get_pairwise_xor(v); v.push_back(1); vector<int> besar=get_pairwise_xor(v); vector<int> selisih=kurang(besar,kecil); for(int j=0;j<selisih.size();j++){ selisih[j]^=satu; balik[selisih[j]]+=(1<<i); } } for(map<int,int>::iterator it=balik.begin();it!=balik.end();++it){ arr[it->second]=it->first; } for(int i=1;i<=n;i++)ans.push_back(arr[i]); return ans; }

Compilation message (stderr)

Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:37:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   for(int j=0;j<selisih.size();j++){
      |               ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...