제출 #50918

#제출 시각아이디문제언어결과실행 시간메모리
50918zetapiUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
4 ms588 KiB
#include "messy.h" #include "bits/stdc++.h" using namespace std; #define pb push_back vector<int> res; int N; 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,vector<int> lol) { vector<int> present,absent,now; for(int B=0;B<N;B++) { if(lol[B]) present.pb(B); else absent.pb(B); } if(low==high) { res[present[0]]=low; 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; vector<int> f(N,0),s(N,1); for(auto A:now) f[A]=1; for(auto A:now) s[A]=0; for(auto A:absent) s[A]=0; solve(low,mid,f); solve(mid+1,high,s); return ; } vector<int> restore_permutation(int n,int w,int r) { /*add_element("0"); compile_set(); check_element("0");*/ vector<int> f(n,1); N=n; res.resize(n); build(0,n-1); compile_set(); solve(0,n-1,f); 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...