제출 #206557

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