제출 #1043707

#제출 시각아이디문제언어결과실행 시간메모리
1043707dpsaveslivesUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms608 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; int n; vector<int> ans; void solve(int l, int r){ //we can do recursion! if(l == r) return; int mid = (l+r)>>1; string s = ""; for(int i = 0;i<n;++i){ s += '0'; } for(int i = l;i<=r;++i){ s[i] = '1'; } for(int i = mid+1;i<=r;++i){ s[i] = '0'; add_element(s); s[i] = '1'; } solve(l,mid); solve(mid+1,r); } void read(int l, int r, vector<int> v){ if(l == r){ ans[v[0]] = l; return; } int mid = (l+r)>>1; string s = ""; for(int i = 0;i<n;++i){ s += '0'; } for(auto x : v){ s[x] = '1'; } vector<int> low, high; for(auto x : v){ s[x] = '0'; if(check_element(s)){ high.push_back(x); } else{ low.push_back(x); } s[x] = '1'; } read(l,mid,low); read(mid+1,r,high); } vector<int> restore_permutation(int N, int w, int r){ n = N; ans = vector<int>(N); solve(0,N-1); compile_set(); vector<int> v; for(int i = 0;i<N;++i){ v.push_back(i); } read(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...