Submission #618132

#TimeUsernameProblemLanguageResultExecution timeMemory
618132TemmieUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms472 KiB
#include "messy.h" #include <bits/stdc++.h> std::vector <int> restore_permutation(int n, int W, int R) { auto wr = [&] (auto&& self, int l, int r) -> void { std::string s(n, '1'); for (int i = l; i <= r; i++) { s[i] = '0'; } if (!(r - l - 1)) { s[l] = '1'; add_element(s); return; } for (int i = l; i <= (r + l) / 2; i++) { s[i] = '1'; add_element(s); s[i] = '0'; } self(self, l, (l + r) / 2); self(self, (l + r) / 2 + 1, r); }; wr(wr, 0, n - 1); std::vector <int> ans(n); auto re = [&] (auto&& self, int l, int r, std::set <int> st) -> void { if (!(r - l - 1)) { std::string s(n, '1'); s[*st.begin()] = '0'; ans[*st.begin()] = l; ans[*next(st.begin())] = r; if (check_element(s)) { std::swap(ans[*st.begin()], ans[*next(st.begin())]); } return; } std::set <int> ts[2]; for (int x : st) { std::string s(n, '0'); for (int i = 0; i < n; i++) { s[i] ^= st.count(i) ^ 1; } s[x] = '1'; ts[check_element(s) ^ 1].insert(x); } self(self, l, (l + r) / 2, ts[0]); self(self, (l + r) / 2 + 1, r, ts[1]); }; std::set <int> st; for (int i = 0; i < n; i++) { st.insert(i); } compile_set(); re(re, 0, n - 1, st); 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...