Submission #50916

#TimeUsernameProblemLanguageResultExecution timeMemory
50916zetapiUnscrambling a Messy Bug (IOI16_messy)C++14
20 / 100
3 ms896 KiB
#include "messy.h" #include "bits/stdc++.h" using namespace std; #define pb push_back vector<int> res; int N; long long power[50]; void build(int low,int high) { if(low==high) return ; string X=""; int mid=(low+high)/2; for(int A=0;A<N;A++) { if(A<low or A>high) X+="1"; else X+="0"; } for(int A=low;A<=mid;A++) { X[A]='1'; add_element(X); X[A]='0'; } build(low,mid); build(mid+1,high); return ; } void solve(int low,int high,long long mask) { vector<int> present,absent,now; for(int B=0;B<N;B++) { if(mask&power[B]) present.pb(B); else absent.pb(B); } if(low==high) { res[low]=present[0]; return ; } string X=""; for(int A=0;A<N;A++) X+="0"; for(auto A:absent) X[A]='1'; for(int A=0;A<N;A++) { if(X[A]=='1') continue; X[A]='1'; if(check_element(X)) now.pb(A); X[A]='0'; } int mid=(low+high)/2; long long cur=0; for(auto A:now) cur^=power[A]; solve(low,mid,cur); solve(mid+1,high,mask-cur); return ; } vector<int> restore_permutation(int n,int w,int r) { /*add_element("0"); compile_set(); check_element("0");*/ power[0]=1; for(int A=1;A<50;A++) power[A]=power[A-1]+power[A-1]; N=n; res.resize(n); build(0,n-1); compile_set(); solve(0,n-1,power[n]-1); return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...