Submission #593086

#TimeUsernameProblemLanguageResultExecution timeMemory
593086FatihSolakUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
7 ms616 KiB
#include <bits/stdc++.h> #include "messy.h" #define N 128 using namespace std; int n; vector<int> ans; void add(int l,int r,set<int> s){ if(l == r)return; string now=""; for(int i = 0;i<n;i++){ now+='0'; } for(auto u:s){ now[u] = '1'; } int m = (l + r)/2; for(int i = l;i<=m;i++){ assert(now[i] == '0'); now[i] = '1'; add_element(now); now[i] = '0'; } set<int> a = s; set<int> b = s; for(int i = l;i<=m;i++){ b.insert(i); } for(int i = m+1;i<=r;i++){ a.insert(i); } add(l,m,a); add(m+1,r,b); } void get(int l,int r,set<int> s,set<int> s2){ // cout << l << " " << r << endl; // for(auto u:s){ // cout << u << " "; // } // cout << endl; // for(auto u:s2){ // cout << u << " "; // } // cout << endl; if(l == r){ ans[*s.begin()] = l; return; } string now=""; for(int i = 0;i<n;i++){ now+='0'; } for(auto u:s2){ now[u] = '1'; } vector<int> v; for(auto u:s){ v.push_back(u); } set<int> onl,onr; onr = s; int m = (l + r)/2; for(int i = l;i<=r;i++){ assert(now[v[i - l]] == '0'); now[v[i - l]] = '1'; if(check_element(now)){ onl.insert(v[i-l]); onr.erase(v[i-l]); } now[v[i - l]] = '0'; } set<int> a = s2; set<int> b = s2; for(auto u:onr){ a.insert(u); } for(auto u:onl){ b.insert(u); } get(l,m,onl,a); get(m+1,r,onr,b); } vector<int> restore_permutation(int n_, int w, int r) { n = n_; add(0,n-1,{}); compile_set(); ans.resize(n); set<int> s; for(int i = 0;i<n;i++){ s.insert(i); } get(0,n-1,s,{}); return ans; }
#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...