Submission #769887

#TimeUsernameProblemLanguageResultExecution timeMemory
769887ZeroCoolUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
3 ms468 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; typedef long long int ll; const int mxn = 3e5 + 5; int n; bool in[mxn]; void run(){ string s; for(int i = 0;i<n;i++)s += char('0' + in[i]); add_element(s); } bool get(){ string s; for(int i = 0;i<n;i++)s += char('0' + in[i]); return check_element(s); } void gen(int l,int r){ if(l >= r)return; int mid = (l+r)/2; for(int i = 0;i<n;i++)in[i] = true; for(int i = l;i<=r;i++)in[i] = false; for(int i = mid+1;i<=r;i++){ in[i] = true; run(); in[i] = false; } gen(l,mid); gen(mid+1,r); } vector<int> ans; void ask(int l,int r, vector<int> v){ if(l == r){ ans[v[0]] = l; return; } int mid = (l+r)/2; for(int i = 0;i<n;i++)in[i] = true; for(auto p : v)in[p] = false; vector<int> v1; vector<int> v2; for(auto p : v){ in[p] = true; if(get())v2.push_back(p); else v1.push_back(p); in[p] = false; } ask(l, mid, v1); ask(mid+1,r,v2); } vector<int> restore_permutation(int N, int w, int r) { n = N; ans.resize(n); gen(0,n-1); compile_set(); vector<int> v; for(int i = 0;i<n;i++)v.push_back(i); ask(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...