Submission #32024

#TimeUsernameProblemLanguageResultExecution timeMemory
32024imeimi2000Unscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
17 ms640 KiB
#include <vector> #include "messy.h" using namespace std; string now; vector<int> per; vector<int> ans; void dnc1(int s, int e) { if (s == e) return; int m = (s + e) / 2; for (int i = m + 1; i <= e; ++i) { now[i] = '1'; add_element(now); now[i] = '0'; } for (int i = m + 1; i <= e; ++i) now[i] = '1'; dnc1(s, m); for (int i = m + 1; i <= e; ++i) now[i] = '0'; now[s] = '1'; dnc1(m + 1, e); now[s] = '0'; } vector<int> group[1024]; void dnc2(int idx, int s, int e) { if (s == e) { per[s] = group[idx].back(); return; } int m = (s + e) / 2; for (int i : group[idx]) { now[i] = '1'; if (check_element(now)) group[idx * 2 + 1].push_back(i); else group[idx * 2].push_back(i); now[i] = '0'; } for (int i : group[idx * 2 + 1]) now[i] = '1'; dnc2(idx * 2, s, m); for (int i : group[idx * 2 + 1]) now[i] = '0'; now[per[s]] = '1'; dnc2(idx * 2 + 1, m + 1, e); now[per[s]] = '0'; } std::vector<int> restore_permutation(int n, int w, int r) { per.resize(n); ans.resize(n); now.resize(n, '0'); dnc1(0, n - 1); compile_set(); group[1].resize(n); for (int i = 0; i < n; ++i) group[1][i] = i; dnc2(1, 0, n - 1); for (int i = 0; i < n; ++i) ans[per[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...