Submission #70792

#TimeUsernameProblemLanguageResultExecution timeMemory
70792VahanUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
4 ms668 KiB
#include <vector> #include<string> #include "messy.h" using namespace std; int n; string s[1000]; vector<int> g; void add_build(int l,int r,int v) { if(l==r) return; string t; for(int i=0;i<n;i++) { if(i>=l && i<=r) t+='0'; else t+='1'; } int mid=(l+r)/2; for(int i=l;i<=mid;i++) { t[i]='1'; add_element(t); t[i]='0'; } add_build(l,mid,2*v); add_build(mid+1,r,2*v+1); } void check_build(int l,int r,int v) { if(l==r) { for(int i=0;i<n;i++) { if(s[v][i]=='0') { g[i]=l; break; } } return; } s[2*v]=s[v]; s[2*v+1]=s[v]; for(int i=0;i<n;i++) { if(s[v][i]=='1') continue; s[v][i]='1'; if(check_element(s[v])) s[2*v+1][i]='1'; else s[2*v][i]='1'; s[v][i]='0'; } int mid=(l+r)/2; check_build(l,mid,2*v); check_build(mid+1,r,2*v+1); } std::vector<int> restore_permutation(int N, int w, int r) { n=N; for(int i=0;i<n;i++) g.push_back(0); add_build(0,n-1,1); compile_set(); for(int i=0;i<n;i++) s[1]+='0'; check_build(0,n-1,1); return g; } /* 4 200 200 2 3 1 0 */
#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...