Submission #441612

#TimeUsernameProblemLanguageResultExecution timeMemory
441612leakedXoractive (IZhO19_xoractive)C++14
100 / 100
7 ms384 KiB
#include "interactive.h" #include <bits/stdc++.h> #define vec vector #define pb push_back #define f first #define s second #define sz(x) (int)x.size() using namespace std; const int N=1e2; int f; //vec<int>produce vec<int> del(vec<int> &a,vec<int> &b,int w){ map<int,int>mp; vec<int>c; for(auto &z : b) mp[z]--; for(auto &z : a) mp[z]++; if(w)mp[0]--; for(auto &z : mp){ int x=z.s/((w?2:1)); while(x--){ if(w) c.pb(z.f^f); else c.pb(z.f); } } sort(c.begin(),c.end()); return c; } vec<int> get(vec<int> inds){ if(!sz(inds)) return vec<int>(); for(auto &z : inds) z++; map<int,int>mp; vec<int>a=inds,b=inds,c; b.pb(1); a=get_pairwise_xor(a),b=get_pairwise_xor(b); return del(b,a,1); } vec<int>have[7],nothave[7]; void era(vec<int> &a,int x){ int j=-1; for(int i=0;i<sz(a);i++){ if(x==a[i])j=i; } assert(j!=-1); a.erase(a.begin()+j,a.begin()+j+1); } vec<int>all; int m; int answ[N]; map<int,int>fck; void rec(int st){ if(st>=7)return; vec<int>vc; for(int i=0;i<m;i++){ if((1<<st)&i) vc.pb(i); } have[st]=get(vc); for(auto &z : have[st]) fck[z]++; // nothave[st]=del(all,have[st],0); rec(st+1); } vector<int> guess(int n) { vector <int> ans; m=n; f=ask(1); all.pb(f); rec(0); for(auto &z : fck) all.pb(z.f); for(int i=0;i<7;i++){ nothave[i]=del(all,have[i],0); } for(int i=0;i<=m;i++){ map<int,int>mp; for(int st=0;st<7;st++){ if((1<<st)&i){ for(auto &z : have[st]){ if(mp[z]==st) mp[z]++; } } else{ for(auto &z : nothave[st]){ if(mp[z]==st) mp[z]++; } } } for(auto &z : mp){ if(z.s==7){ ///it will be good int x=z.f; answ[i]=x; for(int st=0;st<7;st++){ if((1<<st)&i){ era(have[st],x); } else{ era(nothave[st],x); } } } } } ans.pb(f); for(int i=1;i<m;i++){ ans.pb(answ[i]); } return ans; } /* 13 12 99 65 42 6 27 100 45 57 1 34 6 9 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...