제출 #957485

#제출 시각아이디문제언어결과실행 시간메모리
957485aykhnUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
5 ms856 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; int n; vector<int> ans; void create(int l, int r) { if (l + 1 == r) return; string s(n, '1'); for (int i = l; i < r; i++) s[i] = '0'; for (int i = l; i < ((l + r) >> 1); i++) { s[i] = '1'; add_element(s); s[i] = '0'; } create(l, (l + r) >> 1); create((l + r) >> 1, r); } void getans(int l, int r, vector<int> v) { if (l + 1 == r) { ans[v[0]] = l; return; } string s(n, '1'); for (int i : v) s[i] = '0'; vector<int> V[2]; for (int i : v) { s[i] = '1'; int x = check_element(s); s[i] = '0'; if (x) V[0].push_back(i); else V[1].push_back(i); } getans(l, (l + r) >> 1, V[0]); getans((l + r) >> 1, r, V[1]); } vector<int> restore_permutation(int N, int w, int r) { n = N; create(0, n); compile_set(); vector<int> v(n, 0); iota(v.begin(), v.end(), 0); ans.assign(n, 0); getans(0, n, v); 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...