제출 #425248

#제출 시각아이디문제언어결과실행 시간메모리
425248pliamUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
3 ms460 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; #define MAXLOGN 7 #define MAXN 128 typedef vector<int> vi; int N; int p[MAXN]; void fill_w(int l,int r,vi known){//[l,r] not in known string s; for(int i=0;i<N;i++){ s += known[i]?'1':'0'; } for(int i=l;i<=r;i++){ s[i]='1'; add_element(s); s[i]='0'; } } void solve_w(int start=0,int end=N-1){ if(start==end) return; vi known(N); for(int i=0;i<N;i++){ if(start<=i&&i<=end) known[i]=0; else known[i]=1; } int mid=(start+end)/2; fill_w(start,mid,known); solve_w(start,mid); solve_w(mid+1,end); } vi fill_r(vi known){ string s; vi ret=known; for(int i=0;i<N;i++){ s += known[i]?'1':'0'; } for(int i=0;i<N;i++){ if(known[i]) continue; s[i]='1'; if(check_element(s)) ret[i]=1; s[i]='0'; } return ret; } void solve_r(int start,int end,vi known){ if(start==end){ for(int i=0;i<N;i++){ if(!known[i]){ p[i]=start; return; } } } int mid=(start+end)/2; vi ans=fill_r(known); solve_r(mid+1,end,ans); for(int i=0;i<N;i++){ if(known[i]==ans[i]) ans[i]=1; else ans[i]=0; } solve_r(start,mid,ans); } vi restore_permutation(int n, int w, int r) { N=n; solve_w(); compile_set(); vi empty(N,0); solve_r(0,N-1,empty); return vi(p,p+N); }
#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...