제출 #139771

#제출 시각아이디문제언어결과실행 시간메모리
139771toonewbieUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
4 ms532 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; int n; vector <int> p; void add_all(int l, int r) { if (l == r) return; int mid = (l + r) >> 1; string s(n, '1'); for (int i = l; i <= r; i++) s[i] = '0'; for (int i = l; i <= mid; i++) { s[i] = '1'; add_element(s); s[i] = '0'; } add_all(l, mid); add_all(mid + 1, r); } void solve(int l, int r, vector <int> can) { if (l == r) { p[can[0]] = l; return; } int mid = (l + r) >> 1; string s(n, '1'); vector <int> lft, rgt; for (int i : can) s[i] = '0'; for (int i : can) { s[i] = '1'; if (check_element(s) == 1) { lft.push_back(i); } else { rgt.push_back(i); } s[i] = '0'; } solve(l, mid, lft); solve(mid + 1, r, rgt); } vector<int> restore_permutation(int N, int w, int r) { n = N; p.resize(n); add_all(0, n - 1); compile_set(); vector <int> can(n); for (int i = 0; i < n; i++) can[i] = i; solve(0, n - 1, can); 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...