Submission #1022548

#TimeUsernameProblemLanguageResultExecution timeMemory
1022548mansurUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms604 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; #define rall(s) s.rbegin(), s.rend() #define all(s) s.begin(), s.end() #define sz(s) (int)s.size() #define s second #define f first using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; const int N = 2e5 + 5; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); string h = ""; vector<int> p; void bld(int l, int r) { if (l == r) return; int m = (l + r) / 2; for (int i = l; i <= m; i++) { h[i] = '1'; add_element(h); h[i] = '0'; } for (int i = m + 1; i <= r; i++) h[i] = '1'; bld(l, m); for (int i = l; i <= r; i++) { if (i <= m) h[i] = '1'; else h[i] = '0'; } bld(m + 1, r); } void fnd(int l, int r, vector<int> &s) { if (l == r) { p[s[0]] = l; return; } int m = (l + r) / 2; vector<int> tl, tr; for (int i: s) { h[i] = '1'; if (check_element(h)) tl.push_back(i); else tr.push_back(i); h[i] = '0'; } for (int i: tr) h[i] = '1'; fnd(l, m, tl); for (int i: tl) h[i] = '1'; for (int i: tr) h[i] = '0'; fnd(m + 1, r, tr); } vector<int> restore_permutation(int n, int w, int r) { for (int i = 0; i < n; i++) h += '0'; p.resize(n); bld(0, n - 1); compile_set(); vector<int> s; for (int i = 0; i < n; i++) { s.push_back(i); h[i] = '0'; } fnd(0, n - 1, s); 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...