제출 #208528

#제출 시각아이디문제언어결과실행 시간메모리
208528mieszko11bUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
9 ms688 KiB
#include <bits/stdc++.h> using namespace std; #include "messy.h" int n; void insert(int a, int b) { if(a == b) return ; for(int i = a ; i <= (a + b) / 2 ; i++) { string s; for(int j = 0 ; j < n ; j++) if(j == i || j < a || j > b) s += "1"; else s += "0"; add_element(s); } insert(a, (a + b) / 2); insert((a + b) / 2 + 1, b); } vector<int> p; void restore(int a, int b, vector<int> &V) { if(a == b) { p[V[0]] = a; return ; } vector<int> VB1, VB2; bool hlp[130]; memset(hlp, 0, sizeof hlp); for(int x : V) hlp[x] = 1; for(int i : V) { string s; for(int j = 0 ; j < n ; j++) if(j == i || !hlp[j]) s += "1"; else s += "0"; if(check_element(s)) VB1.push_back(i); else VB2.push_back(i); } restore(a, (a + b) / 2, VB1); restore((a + b) / 2 + 1, b, VB2); } std::vector<int> restore_permutation(int n, int w, int r) { ::n = n; insert(0, n - 1); compile_set(); vector<int> V; for(int i = 0 ; i < n ; i++) V.push_back(i); p.resize(n); restore(0, n - 1, V); 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...