Submission #288367

#TimeUsernameProblemLanguageResultExecution timeMemory
288367arayiUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms576 KiB
#include <bits/stdc++.h> #include "messy.h" #define ad push_back using namespace std; int n, sm, sm1; vector <int> p; void rec1(int l, int r, string s) { if(l == r) return; int md = (l + r)/2; for (int i = l; i <= md; i++) { s[i] = '1'; add_element(s); s[i] = '0'; } for (int i = md + 1; i <= r; i++) s[i] = '1'; rec1(l, md, s); for (int i = md + 1; i <= r; i++) s[i] = '0'; for (int i = l; i <= md; i++) s[i] = '1'; rec1(md + 1, r, s); } void rec(int l, int r, string s, vector <int> sm) { if(l == r) { p[l] = sm[0]; return; } int md = (l + r)/2; vector <int> a, b; for(auto p : sm) { s[p] = '1'; bool bl = check_element(s); if(bl) a.ad(p); else b.ad(p); s[p] = '0'; } for(auto p : b) s[p] = '1'; rec(l, md, s, a); for(auto p : b) s[p] = '0'; for(auto p : a) s[p] = '1'; rec(md + 1, r, s, b); } vector<int> restore_permutation(int N, int w, int r) { n = N; string s; vector <int> sm; for (int i = 0; i < n; i++) s += '0', sm.ad(i); rec1(0, n - 1, s); p.resize(n); compile_set(); rec(0, n - 1, s, sm); sm = p; for (int i = 0; i < n; i++) p[sm[i]] = i; 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...