Submission #543699

#TimeUsernameProblemLanguageResultExecution timeMemory
543699fuad27Unscrambling a Messy Bug (IOI16_messy)C++17
0 / 100
2 ms468 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; string s = ""; int n; vector<int> ans; void fill(int l, int r, char c) { for(int i = l;i<=r;i++) { s[i] = c; } } void add(int l, int r) { fill(0, n-1, '0'); fill(0, l-1, '1'); fill(r+1, n-1, '1'); int mid = (l+r)/2; for(int i = l;i<=mid;i++) { s[i] = '1'; add_element(s); s[i] = '0'; } add(l, mid); add(mid+1, r); } void solve(vector<int> v, int l, int r) { if(l == r) { ans[l] = v[0]; } fill(0, n-1, '0'); fill(0, l-1, '1'); fill(r+1, n-1, '1'); int mid = (l+r)>>1ll; vector<int> left, right; for(int i:v) { s[i] = '1'; if(check_element(s)) { left.push_back(i); } else right.push_back(i); s[i] = '0'; } solve(left, l, mid); solve(right, mid+1, r); } std::vector<int> restore_permutation(int N, int w, int r) { n = N; for(int i = 0;i<n;i++)s+="0"; vector<int> v(n); ans.resize(n); iota(v.begin(), v.end(), 1); add(0, n-1); compile_set(); solve(v, 0, n-1); //for(int i:ans)cout << i << " "; 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...