제출 #421141

#제출 시각아이디문제언어결과실행 시간메모리
421141dxz05Unscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
2 ms468 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; int n; vector<int> p; void add(int l, int r){ if (l == r) return; int m = (l + r) >> 1; string s(n, '1'); for (int i = l; i <= r; i++) s[i] = '0'; for (int i = l; i <= m; i++) { s[i] = '1'; add_element(s); s[i] = '0'; } add(l, m); add(m + 1, r); } void build(int l, int r, vector<int> v){ if (l == r){ p[v[0]] = l; return; } vector<int> lf, rg; string s(n, '1'); for (int i : v) s[i] = '0'; for (int i : v){ s[i] = '1'; if (check_element(s)){ lf.push_back(i); } else rg.push_back(i); s[i] = '0'; } int m = (l + r) >> 1; build(l, m, lf); build(m + 1, r, rg); } vector<int> restore_permutation(int _n, int w, int r) { n = _n; p.resize(n); add(0, n - 1); compile_set(); vector<int> v(n); for (int i = 0; i < n; i++) v[i] = i; build(0, n - 1, v); 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...