Submission #789154

#TimeUsernameProblemLanguageResultExecution timeMemory
789154Sohsoh84Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms504 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; const int MAXN = 1e6 + 10; #define sep ' ' #define debug(x) cerr << #x << ": " << x << endl; int n, P[MAXN]; void ask(string s, int l, int r) { if (r - l + 1 < 2) return; int mid = (l + r) >> 1; for (int i = l; i <= mid; i++) { s[i] = '1'; add_element(s); s[i] = '0'; } for (int i = l; i <= mid; i++) s[i] = '1'; ask(s, mid + 1, r); for (int i = l; i <= mid; i++) s[i] = '0'; for (int i = mid + 1; i <= r; i++) s[i] = '1'; ask(s, l, mid); } void get(string s, int l, int r, vector<int> poss) { if (l == r) { P[poss.front()] = l; return; } vector<int> f[2]; for (int e : poss) { s[e] = '1'; if (check_element(s)) f[0].push_back(e); else f[1].push_back(e); s[e] = '0'; } int mid = (l + r) >> 1; for (int e : f[0]) s[e] = '1'; get(s, mid + 1, r, f[1]); for (int e : f[0]) s[e] = '0'; for (int e : f[1]) s[e] = '1'; get(s, l, mid, f[0]); } vector<int> restore_permutation(int n_, int w, int r) { n = n_; string s; vector<int> vec; for (int i = 0; i < n; i++) { vec.push_back(i); s.push_back('0'); } ask(s, 0, n - 1); compile_set(); get(s, 0, n - 1, vec); vector<int> ans; for (int i = 0; i < n; i++) ans.push_back(P[i]); return ans; }
#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...