제출 #163994

#제출 시각아이디문제언어결과실행 시간메모리
163994WLZUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
12 ms636 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; vector<int> a; int n; void solve(int l, int r, set<int> st) { if (l == r) { a[l] = *st.begin(); return; } string s(n, '0'); for (int i = 0; i < n; i++) { if (!st.count(i)) { s[i] = '1'; } } set<int> tmp_l, tmp_r; for (auto& x : st) { s[x] = '1'; if (check_element(s)) { tmp_l.insert(x); } else { tmp_r.insert(x); } s[x] = '0'; } solve(l, (l + r) / 2, tmp_l); solve((l + r) / 2 + 1, r, tmp_r); } vector<int> restore_permutation(int _n, int w, int r) { n = _n; for (int k = 2; k <= n; k += k) { for (int i = 0; i + k - 1 < n; i += k) { string s(n, '1'); for (int j = i; j < i + k; j++) { s[j] = '0'; } for (int j = i; j < i + k / 2; j++) { s[j] = '1'; add_element(s); s[j] = '0'; } } } compile_set(); a.assign(n, -1); set<int> st; for (int i = 0; i < n; i++) { st.insert(i); } solve(0, n - 1, st); vector<int> ans(n); for (int i = 0; i < n; i++) { ans[a[i]] = 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...