Submission #815145

#TimeUsernameProblemLanguageResultExecution timeMemory
815145PikachuUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms468 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; vector<int> restore_permutation(int n, int w, int r) { vector<int> ans(n, -1); auto init = [&](auto init, int l, int r) -> void { if (l == r) return; string s(n, '1'); for (int i = l; i <= r; i++) s[i] = '0'; int mid = (l + r) / 2; for (int i = l; i <= mid; i++) { s[i] = '1'; add_element(s); s[i] = '0'; } init(init, l, mid); init(init, mid + 1, r); }; init(init, 0, n - 1); compile_set(); auto process = [&](auto process, int l, int r, vector<int> can) -> void { if (l == r) { ans[can[0]] = l; return; } string s(n, '1'); for (int x : can) s[x] = '0'; vector<int> nxcan[2]; for (int x : can) { s[x] = '1'; nxcan[!check_element(s)].push_back(x); s[x] = '0'; } int mid = (l + r) >> 1; process(process, l, mid, nxcan[0]); process(process, mid + 1, r, nxcan[1]); }; vector<int> can(n); iota(can.begin(), can.end(), 0); process(process, 0, n - 1, can); 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...