제출 #293679

#제출 시각아이디문제언어결과실행 시간메모리
293679VodkaInTheJarUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
2 ms512 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; int n; void add_elements(int l, int r) { if (l == r) return; int mid = (l + r) / 2; string s; for (int i = 0; i < n; i++) s += "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_elements(l, mid); add_elements(mid + 1, r); } int p[128]; void get_elements(int l, int r, vector <int> el) { if (l == r) { p[el[0]] = l; return; } vector <int> left; string s; for (int i = 0; i < n; i++) s += "1"; for (auto i: el) s[i] = '0'; for (auto i: el) { s[i] = '1'; if (check_element(s)) left.push_back(i); s[i] = '0'; } vector <int> right; for (auto i: el) { bool is = false; for (auto j: left) if (i == j) { is = true; break; } if (!is) right.push_back(i); } int mid = (l + r) / 2; get_elements(l, mid, left); get_elements(mid + 1, r, right); } vector <int> restore_permutation(int _n, int w, int r) { n = _n; add_elements(0, n-1); compile_set(); vector <int> v; for (int i = 0; i < n; i++) v.push_back(i); get_elements(0, n-1, v); vector <int> ans; for (int i = 0; i < n; i++) ans.push_back(p[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...