Submission #58425

#TimeUsernameProblemLanguageResultExecution timeMemory
58425FLDutchmanUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
4 ms640 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; typedef int INT; #define pb push_back #define FOR(i, l, r) for(int i = (l); i < (r); i++) #define fst first #define snd second #define int long long typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef long long ll; const ll INF = 1e15; int N; vector<INT> p; void buildSet(int l, int r){ //cout << "Building " << l << " " << r << endl; if(l + 1 == r) return; string s(N, '0'); FOR(i, 0, l) s[i] = '1'; FOR(i, r, N) s[i] = '1'; int m = (l+r)/2; FOR(i, l, m){ s[i] = '1'; add_element(s); s[i] = '0'; } buildSet(l, m); buildSet(m, r); } void getPerm(int l, int r, vi elems){ if(elems.size() == 1) { p[elems[0]] = l; return; } vi lelems, relems; string s(N, '1'); for(int i : elems) s[i] = '0'; for(int i : elems) { s[i] = '1'; if(check_element(s)) lelems.pb(i); else relems.pb(i); s[i] = '0'; } int m = (l+r)/2; getPerm(l, m, lelems); getPerm(m, r, relems); } std::vector<INT> restore_permutation(INT n, INT w, INT r) { N = n; p.assign(n, -1); buildSet(0, N); compile_set(); vi start; FOR(i, 0, N) start.pb(i); getPerm(0, N, start); return p; } /* 8 24 24 1 3 2 5 6 7 0 4 */
#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...