Submission #593281

#TimeUsernameProblemLanguageResultExecution timeMemory
593281Soumya1Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms512 KiB
#include <bits/stdc++.h> #include "messy.h" #ifdef __LOCAL__ #include <debug_local.h> #endif using namespace std; int n; vector<int> ans; void insert(int l, int r) { if (l == r) return; int m = (l + r) / 2; string s = string(n, '1'); for (int j = l; j <= r; j++) s[j] = '0'; for (int i = l; i <= m; i++) { s[i] = '1'; add_element(s); s[i] = '0'; } insert(l, m); insert(m + 1, r); } void solve(int l, int r, vector<int> pos) { if (l == r) { ans[pos[0]] = l; return; } int m = (l + r) / 2; string s = string(n, '1'); for (int i : pos) s[i] = '0'; vector<int> mark(n), left, right; for (int i : pos) { s[i] = '1'; if (check_element(s)) { mark[i] = 1; } s[i] = '0'; } for (int i : pos) { if (mark[i]) left.push_back(i); else right.push_back(i); } solve(l, m, left); solve(m + 1, r, right); } vector<int> restore_permutation(int N, int w, int r) { n = N; ans.resize(n); insert(0, n - 1); compile_set(); vector<int> a(n); iota(a.begin(), a.end(), 0); solve(0, n - 1, a); 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...