Submission #426361

#TimeUsernameProblemLanguageResultExecution timeMemory
426361zoooma13Unscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
3 ms512 KiB
#include "bits/stdc++.h" #include "messy.h" using namespace std; vector <string> gen(int n){ if(n == 1) return {}; vector <string> cur; for(int i = n/2; i < n; i++){ string s(n ,'0'); s[i] = '1'; cur.push_back(s); } auto sub = gen(n/2); for(auto&s : sub) cur.push_back(string(n/2 ,'1') + s); for(auto&s : sub) cur.push_back(s + string(n/2 ,'1')); return cur; } int n; vector <int> p; void solve(vector <int> active){ if(active.size() == 1) return; string s(n ,'1'); for(int i : active) s[i] = '0'; vector <int> good ,bad; for(int i : active){ string t = s; t[i] = '1'; if(check_element(t)) good.push_back(i); else bad.push_back(i); } int b = __builtin_ctz(active.size())-1; for(int&g : good) p[g] |= 1<<b; solve(good); solve(bad); } vector<int> restore_permutation(int _n, int w, int r){ n = _n; p.resize(n); for(auto&s : gen(n)) add_element(s); compile_set(); vector <int> range; for(int i = 0; i < n; i++) range.push_back(i); solve(range); return p; }
#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...