Submission #226851

#TimeUsernameProblemLanguageResultExecution timeMemory
226851VEGAnnUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
6 ms640 KiB
#include <bits/stdc++.h> #include "messy.h" #define PB push_back using namespace std; const int N = 128; vector<int> seg[2][N], res, vc; string s, l[N], r[N]; bool mrk[N]; std::vector<int> restore_permutation(int n, int w, int r) { int lg = 0; while ((1 << lg) < n) lg++; s = ""; for (int i = 0; i < n; i++) s += "1"; for (int it = 0; it < lg; it++){ int len = n / (1 << (it + 1)); for (int i = 0; i < n; i += len * 2){ for (int j = 0; j < len + len; j++) s[i + j] = '0'; for (int j = 0; j < len; j++){ s[i + j] = '1'; add_element(s); s[i + j] = '0'; } for (int j = 0; j < len + len; j++) s[i + j] = '1'; } } compile_set(); for (int i = 0; i < n; i++) seg[0][0].PB(i); for (int it = 0; it < lg; it++){ int par = (it & 1); int len = n / (1 << (it + 1)); for (int i = 0; i < (1 << (it + 1)); i++) seg[par ^ 1][i].clear(); fill(mrk, mrk + n, 0); for (int i = 0, id = 0; i < n; i += len * 2, id++){ for (int x : seg[par][id]) s[x] = '0'; for (int x : seg[par][id]){ s[x] = '1'; if (check_element(s)) mrk[x] = 1; s[x] = '0'; } for (int x : seg[par][id]) s[x] = '1'; } for (int id = 0, i = 0; i < n; id++, i += len * 2){ int lf = id + id; int rt = id + id + 1; for (int x : seg[par][id]) if (mrk[x]) seg[par ^ 1][lf].PB(x); else seg[par ^ 1][rt].PB(x); } } res.clear(); vc.clear(); for (int i = 0; i < n; i++) vc.PB(seg[lg & 1][i][0]); res.resize(n); for (int kl = 0; kl < 1; kl++){ for (int i = 0; i < n; i++) res[vc[i]] = i; vc = res; } return res; }
#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...