Submission #135568

#TimeUsernameProblemLanguageResultExecution timeMemory
135568ckodserUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
17 ms10080 KiB
#include<bits/stdc++.h> #include "messy.h" #define ll int #define pb push_back #define mp make_pair #define ld long double #define F first #define S second #define pii pair<ll,ll> using namespace :: std; const ll maxn=2e5+500; const ll inf=1e9+900; vector<ll> vec[maxn]; void bild(ll l,ll r,ll node){ for(ll i=l;i<r;i++){ vec[node].pb(i); } if(l+1==r)return; ll mid=(l+r)/2; bild(l,mid,2*node); bild(mid,r,2*node+1); } vector<ll> p[maxn]; vector<int> restore_permutation(int n, int w, int r) { bild(0,n,1); string base; for(ll i=0;i<n;i++){ base+="0"; } for(ll i=2;i<maxn;i+=2){ if(vec[i].size()){ vector<ll> f; ll v=i/2; while(v!=1){ for(auto u:vec[v^1]){ f.pb(u); } v/=2; } string s=base; for(auto r:f){ s[r]='1'; } for(auto r:vec[i]){ s[r]='1'; add_element(s); s[r]='0'; } } } compile_set(); for(ll i=0;i<n;i++){ p[1].pb(i); } for(ll i=2;i<maxn;i+=2){ if(vec[i].size()){ vector<ll> f; ll v=i/2; while(v!=1){ for(auto u:p[v^1]){ f.pb(u); } v/=2; } string s=base; for(auto r:f){ s[r]='1'; } for(auto r:p[i/2]){ s[r]='1'; if(check_element(s)){ p[i].pb(r); }else{ p[i^1].pb(r); } s[r]='0'; } } } vector<ll> ans; ans.resize(n); for(ll i=0;i<maxn;i++){ if(vec[i].size()==1){ ans[p[i][0]]=vec[i][0]; } } 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...