Submission #760764

#TimeUsernameProblemLanguageResultExecution timeMemory
760764DaktoUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms480 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; int n; std::vector<int> res; void gen_rec(int l, int r){ if(l+1==r) return; string s(n,'0'); for(int i=l; i<r; i++) s[i]='1'; int mid=(l+r)/2; for(int i=l; i<mid; i++){ s[i]='0'; add_element(s); s[i]='1'; } gen_rec(l,mid); gen_rec(mid,r); } void gen_res(int l, int r, set<int> st){ if(l+1==r){ res[*begin(st)]=l; return; } string s(n, '0'); for(auto i:st) s[i]='1'; set<int> s1,s2; for(auto i:st) { s[i]='0'; bool t=check_element(s); s[i]='1'; if(t) s1.insert(i); else s2.insert(i); } int mid=(l+r)/2; gen_res(l,mid,s1); gen_res(mid,r,s2); } std::vector<int> restore_permutation(int N, int w, int r) { n=N; res.resize(n); gen_rec(0,n); compile_set(); set<int> st; for(int i=0; i<n; i++) st.insert(i); gen_res(0,n,st); 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...