Submission #419863

#TimeUsernameProblemLanguageResultExecution timeMemory
419863xt0r3Unscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
2 ms460 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; vector<int> ans; void add(int l, int r, int n){ if(l == r) return; int m = (l + r) / 2; string s(n, '1'); for(int i = l; i <= r; i++){ s[i] = '0'; } for(int i = l; i <= m; i++){ s[i] = '1'; add_element(s); s[i] = '0'; } add(l, m, n); add(m + 1, r, n); } void get(int l, int r, int n, const vector<int> &perm){ if(r == l){ ans[perm[0]] = l; return; } int m = (l + r) / 2; string s(n, '1'); vector<int> on, off; for(int x : perm) s[x] = '0';//perm-ben vannak a lehetseges dolgok for(int x : perm){ s[x] = '1'; (check_element(s) ? on : off).push_back(x); s[x] = '0'; } get(l, m, n, on); get(m + 1, r, n, off); } std::vector<int> restore_permutation(int n, int w, int r) { ans.resize(n); add(0, n - 1, n); compile_set(); vector<int> start(n); iota(start.begin(), start.end(), 0); get(0, n - 1, n, start); 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...