Submission #817717

#TimeUsernameProblemLanguageResultExecution timeMemory
817717pavementUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
1 ms468 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; #define pb push_back int n; vector<int> ans_r; void dnc(int in_l, int in_r, vector<int> out) { assert(in_r - in_l + 1 == (int)out.size()); if (in_l == in_r) { ans_r[in_l] = out[0]; return; } vector<int> fh_out, sh_out; string cur = ""; for (int i = 0; i < n; i++) { cur.pb(!binary_search(out.begin(), out.end(), i) + '0'); } for (int i = 0; i < (int)out.size(); i++) { cur[out[i]] = '1'; if (check_element(cur)) { fh_out.pb(out[i]); } else { sh_out.pb(out[i]); } cur[out[i]] = '0'; } int in_m = (in_l + in_r) / 2; dnc(in_l, in_m, fh_out); dnc(in_m + 1, in_r, sh_out); } vector<int> restore_permutation(int n, int w, int r) { ::n = n; for (int i = 1; (1 << i) <= n; i++) { for (int j = 0; j < n; j += (1 << i)) { string base = ""; for (int k = 0; k < n; k++) { base.pb('1'); } for (int k = j; k < j + (1 << i); k++) { base[k] = '0'; } for (int k = j; k < j + (1 << (i - 1)); k++) { base[k] = '1'; add_element(base); base[k] = '0'; } } } compile_set(); vector<int> all; for (int i = 0; i < n; i++) all.pb(i); ans_r.resize(n); dnc(0, n - 1, all); vector<int> ans(n); for (int i = 0; i < n; i++) { ans[ans_r[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...