Submission #641978

#TimeUsernameProblemLanguageResultExecution timeMemory
641978QwertyPiUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
2 ms468 KiB
#include <vector> #include "messy.h" #include <bits/stdc++.h> using namespace std; int n; string s; int p[128]; vector<int> a[128], a_sw[128]; std::vector<int> restore_permutation(int n, int w, int r) { ::n = n; s.resize(n); for(int sz = n / 2; sz; sz /= 2){ for(int i = 0; i < n; i += sz * 2){ int l = i + sz, r = i + sz * 2; for(int j = l; j < r; j++){ fill(begin(s), begin(s) + n, '0'); fill(begin(s) + i, begin(s) + i + sz * 2, '1'); s[j] = '0'; add_element(s); } } } compile_set(); for(int i = 0; i < n; i++) a[0].push_back(i); for(int sz = n / 2; sz; sz /= 2){ for(int i = 0; i < n / sz / 2; i++){ for(auto j : a[i]){ fill(begin(s), begin(s) + n, '0'); for(auto k : a[i]){ s[k] = '1'; } s[j] = '0'; bool c = check_element(s); if(c) a_sw[i * 2 + 1].push_back(j); else a_sw[i * 2 + 0].push_back(j); } } for(int i = 0; i < n; i++){ swap(a[i], a_sw[i]); } for(int i = 0; i < n; i++){ a_sw[i].clear(); } } vector<int> result(n); for(int i = 0; i < n; i++) result[a[i][0]] = i; return result; }
#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...