Submission #639489

#TimeUsernameProblemLanguageResultExecution timeMemory
639489piOOEUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms480 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; vector<int> restore_permutation(int n, int w, int r) { vector<int> p(n, -1); function<void(int, int)> init = [&](int l, int r) { if (l + 1 == r) { return; } string s(n, '1'); int mid = (l + r) >> 1; fill(s.begin() + l, s.begin() + r, '0'); for (int i = mid; i < r; ++i) { s[i] = '1'; add_element(s); s[i] = '0'; } init(l, mid); init(mid, r); }; init(0, n); compile_set(); function<void(int, int, vector<int>)> solve = [&](int l, int r, vector<int> a) { if (l + 1 == r) { p[a[0]] = l; return; } string s(n, '1'); for (int i: a) { s[i] = '0'; } vector<int> on, off; for (int i: a) { s[i] = '1'; if (check_element(s)) { on.push_back(i); } else { off.push_back(i); } s[i] = '0'; } int mid = (l + r) >> 1; solve(l, mid, off); solve(mid, r, on); }; vector<int> a(n); iota(a.begin(), a.end(), 0); solve(0, n, a); 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...