Submission #428371

#TimeUsernameProblemLanguageResultExecution timeMemory
428371jk410Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms488 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; int N; vector<int> ans; void write(int s,int e){ if (s==e) return; string t=""; for (int i=0; i<N; i++) t.push_back('1'); int m=(s+e)>>1; for (int i=s; i<=e; i++) t[i]='0'; for (int i=s; i<=m; i++){ t[i]='1'; add_element(t); t[i]='0'; } write(s,m); write(m+1,e); } void read(int s,int e,vector<int> v){ if (s==e){ ans[v[0]]=s; return; } vector<int> l,r; string t=""; for (int i=0; i<N; i++) t.push_back('1'); for (int i:v) t[i]='0'; for (int i:v){ t[i]='1'; if (check_element(t)) l.push_back(i); else r.push_back(i); t[i]='0'; } int m=(s+e)>>1; read(s,m,l); read(m+1,e,r); } vector<int> restore_permutation(int n, int w, int r) { N=n; ans.resize(N); write(0,N-1); compile_set(); vector<int> v; for (int i=0; i<N; i++) v.push_back(i); read(0,N-1,v); 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...