제출 #667151

#제출 시각아이디문제언어결과실행 시간메모리
667151LoboUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms504 KiB
#include<bits/stdc++.h> #include "messy.h" using namespace std; int n; vector<int> p; void add(int l, int r) { if(l == r) { return; } int mid = (l+r)>>1; string s; for(int i = 0; i < n; i++) { if(l <= i && i <= r) s+= '0'; else s+= '1'; } for(int i = l; i <= mid; i++) { s[i] = '1'; add_element(s); s[i] = '0'; } add(l,mid); add(mid+1,r); } void check(int l, int r, set<int> st) { if(l == r) { p[*st.begin()] = l; return; } int mid = (l+r)>>1; string s; for(int i = 0; i < n; i++) { if(st.count(i)) s+= '0'; else s+= '1'; } set<int> stl,str; for(auto x : st) { s[x] = '1'; if(check_element(s)) stl.insert(x); else str.insert(x); s[x] = '0'; } check(l,mid,stl); check(mid+1,r,str); } vector<int> restore_permutation(int N, int w, int r) { n = N; add(0,n-1); compile_set(); p.resize(n); set<int> st; for(int i = 0; i < n; i++) st.insert(i); check(0,n-1,st); 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...