제출 #619976

#제출 시각아이디문제언어결과실행 시간메모리
619976Bench0310Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms500 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; typedef long long ll; int n; vector<int> res; void gen(int l,int r) { if(l<r) { int m=(l+r)/2; for(int i=l;i<=m;i++) { string s(n,'0'); s[i]='1'; for(int j=0;j<l;j++) s[j]='1'; for(int j=r+1;j<n;j++) s[j]='1'; add_element(s); } gen(l,m); gen(m+1,r); } } vector<int> neg(vector<int> v) { vector<bool> b(n,0); for(int x:v) b[x]=1; vector<int> u; for(int i=0;i<n;i++) if(!b[i]) u.push_back(i); return u; } void solve(int l,int r,vector<int> v) { if(l==r) res[v[0]]=l; else { string s(n,'0'); for(int x:neg(v)) s[x]='1'; vector<int> one,two; for(int i=0;i<n;i++) { if(s[i]=='0') { s[i]='1'; if(check_element(s)) one.push_back(i); else two.push_back(i); s[i]='0'; } } int m=(l+r)/2; solve(l,m,one); solve(m+1,r,two); } } vector<int> restore_permutation(int tn,int w,int r) { n=tn; gen(0,n-1); compile_set(); vector<int> v(n); for(int i=0;i<n;i++) v[i]=i; res.assign(n,-1); solve(0,n-1,v); 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...