Submission #852543

#TimeUsernameProblemLanguageResultExecution timeMemory
852543NeroZeinUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms1112 KiB
#include "messy.h" #include "bits/stdc++.h" using namespace std; void init(int l, int r, string& ask) { if (l == r) { return; } int m = (l + r) / 2; for (int i = l; i <= m; ++i) { ask[i] = '1'; add_element(ask); ask[i] = '0'; } for (int i = l; i <= m; ++i) { ask[i] = '1'; } init(m + 1, r, ask); for (int i = l; i <= m; ++i) { ask[i] = '0'; } for (int i = m + 1; i <= r; ++i) { ask[i] = '1'; } init(l, m, ask); for (int i = m + 1; i <= r; ++i) { ask[i] = '0'; } } vector<int> go(int l, int r, vector<int>& p, string& ask) { if (l == r) { return {p[0]}; } vector<int> pl, pr; int m = (l + r) >> 1; for (int i = 0; i < (int) p.size(); ++i) { ask[p[i]] = '1'; if (check_element(ask)) { pl.push_back(p[i]); } else { pr.push_back(p[i]); } ask[p[i]] = '0'; } for (int i = 0; i < (int) pl.size(); ++i) { ask[pl[i]] = '1'; } vector<int> rret = go(m + 1, r, pr, ask); for (int i = 0; i < (int) pl.size(); ++i) { ask[pl[i]] = '0'; } for (int i = 0; i < (int) pr.size(); ++i) { ask[pr[i]] = '1'; } vector<int> ret = go(l, m, pl, ask); for (int i = 0; i < (int) pr.size(); ++i) { ask[pr[i]] = '0'; } for (int i : rret) { ret.push_back(i); } return ret; } vector<int> restore_permutation(int n, int w, int r) { string e(n, '0'); init(0, n - 1, e); compile_set(); vector<int> p(n); iota(p.begin(), p.end(), 0); e = string(n, '0'); vector<int> id = go(0, n - 1, p, e); vector<int> ans(n); for (int i = 0; i < (int) id.size(); ++i) { ans[id[i]] = i; } 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...