제출 #138867

#제출 시각아이디문제언어결과실행 시간메모리
138867rondojimUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
4 ms632 KiB
#include "messy.h" #include <bits/stdc++.h> #define eb emplace_back using namespace std; const int MAXN = 155; int Ans[MAXN]; int N; void make(int s, int e) { if(s == e) return; int m = (s+e) >> 1; string bstr; for(int i = 0; i < N; i++) bstr += "1"; for(int i = s; i <= e; i++) bstr[i] = '0'; for(int i = s; i <= m; i++) { string str = bstr; str[i] = '1'; add_element(str); } make(s, m); make(m+1, e); } void solve(vector<int> V, int s, int e) { if(s == e) { Ans[s] = V[0]; return; } int m = (s+e) >> 1; string bstr; for(int i = 0; i < N; i++) bstr += "1"; for(int v : V) bstr[v] = '0'; vector<int> VL, VR; for(int v : V) { string str = bstr; str[v] = '1'; (check_element(str) ? VL : VR).eb(v); } solve(VL, s, m); solve(VR, m+1, e); } std::vector<int> restore_permutation(int n, int w, int r) { ::N = n; make(0, N-1); compile_set(); { vector<int> V; for(int i = 0; i < N; i++) V.eb(i); solve(V, 0, N-1); } vector<int> ret(N); for(int i = 0; i < N; i++) ret[Ans[i]] = i; return ret; }
#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...