Submission #593099

#TimeUsernameProblemLanguageResultExecution timeMemory
593099alirezasamimi100Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms468 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; #define pb push_back int n; vector<int> ans; void fsolve(int l, int r){ if(r-l==1) return; int m=(l+r)>>1; string s; for(int i=0; i<n; i++){ if(i<l || i>=r) s.pb('1'); else s.pb('0'); } for(int i=l; i<m; i++){ s[i]='1'; add_element(s); s[i]='0'; } fsolve(l,m); fsolve(m,r); } void ssolve(int l, int r, vector<int> t){ if(r-l==1){ ans[t[0]]=l; return; } int m=(l+r)>>1; vector<int> v1,v2; string s; for(int i=0; i<n; i++) s.pb('1'); for(int i : t) s[i]='0'; for(int i : t){ s[i]='1'; if(check_element(s)){ v1.pb(i); }else{ v2.pb(i); } s[i]='0'; } ssolve(l,m,v1); ssolve(m,r,v2); } vector<int> restore_permutation(int n, int w, int r) { ::n=n; ans.resize(n); vector<int> t; for(int i=0; i<n; i++) t.pb(i); fsolve(0,n); compile_set(); ssolve(0,n,t); return ans; }
#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...