Submission #591998

#TimeUsernameProblemLanguageResultExecution timeMemory
591998VanillaUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms500 KiB
#include <bits/stdc++.h> #include "messy.h" #include <vector> using namespace std; vector<int> restore_permutation(int n,int w,int r) {vector<int>p(n);auto o=[&](int l, int r, auto &&o) {if (l >= r) return;int m = (l + r) / 2;string s(n, '0');for (int i = l; i <= r; i++){s[i] = '1';}for (int i = l; i <= m; i++){s[i] = '0';add_element(s);s[i] = '1';}o(l, m, o);o(m + 1, r, o);};o(0, n - 1, o);compile_set();auto x = [&] (int l, int r, vector <int> ps, auto &&x) {if (ps.size() == 1) return;int m = (l + r) / 2;string s(n, '0');vector <int> a,b;for (int i: ps) s[i] = '1';for (int i: ps) {s[i] = '0';if(check_element(s))a.push_back(i);else b.push_back(i),p[i]+=ps.size()/2;s[i]='1';}x(l,m,a,x);x(m+1,r,b,x);};vector<int>v;for(int i=0;i<n;i++)v.push_back(i);x(0,n-1,v,x);return p;}
#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...