Submission #597530

#TimeUsernameProblemLanguageResultExecution timeMemory
597530Valaki2Unscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
2 ms468 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; #define n N #define pb push_back #define mp make_pair #define pii pair<int, int> #define fi first #define se second int n; vector<int> p; void add_range(int l, int r) { if(l == r) { return; } int mid = (l + r) / 2; string s(n, '1'); for(int i = l; i <= r; i++) { s[i - 1] = '0'; } for(int i = l; i <= mid; i++) { s[i - 1] = '1'; add_element(s); s[i - 1] = '0'; } add_range(l, mid); add_range(mid + 1, r); } void check_range(int l, int r, string s) { if(l == r) { int idx = -1; for(int i = 0; i < n; i++) { if(s[i] == '0') { idx = i; } } p[idx] = l - 1; return; } int mid = (l + r) / 2; vector<int> left_part; vector<int> right_part; for(int i = 0; i < n; i++) { if(s[i] == '0') { s[i] = '1'; if(check_element(s)) { left_part.pb(i); } else { right_part.pb(i); } s[i] = '0'; } } for(int x : right_part) { s[x] = '1'; } check_range(l, mid, s); for(int x : right_part) { s[x] = '0'; } for(int x : left_part) { s[x] = '1'; } check_range(mid + 1, r, s); for(int x : left_part) { s[x] = '0'; } } void solve() { add_range(1, n); compile_set(); check_range(1, n, string(n, '0')); } #undef n vector<int> restore_permutation(int n, int w, int r) { srand(4242); N = n; p.assign(N, -1); solve(); 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...