Submission #165284

#TimeUsernameProblemLanguageResultExecution timeMemory
165284NightlightUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
15 ms508 KiB
#include <bits/stdc++.h> using namespace std; #include "messy.h" vector<int> ans; int N; void add(int l, int r){ int mid = (l+r)>>1; string front(l, '1'), back(N-r-1, '1'), now; for(int i = l; i <=r; i++)now += "0"; now[0] = '1'; // cout << front << now << back << "\n"; add_element(front + now + back); for(int i = 1; i <= mid-l; i++){ swap(now[i-1], now[i]); // cout << front + now + back << "\n"; add_element(front + now + back); } if(r - l > 1){ add(l, mid); add(mid+1, r); } } void ask(bitset<128> pos, int l, int r){ // cout << l << " " << r << "\n"; string toask(N, '0'); for(int i = 0; i < N; i++){ if(pos[i] == 1)toask[i] = '1'; } if(r - l < 2){ for(int i = 0; i < N;i++){ if(pos[i] == 0){ toask[i] = '1'; // cout << toask << " " << check_element(toask) << "\n"; if(check_element(toask))ans[i] = l; else ans[i] = r; toask[i] = '0'; } } return; } bitset<128> left; bitset<128> right; left = pos; right = pos; for(int i = 0; i < N; i++){ if(pos[i] == 0){ toask[i] = '1'; // cout << toask << " " << check_element(toask) << "\n"; if(check_element(toask))right[i] = 1; else left[i] = 1; toask[i] = '0'; }; } int mid = (l+r)>>1; ask(left, l, mid); ask(right, mid+1, r); } vector<int> restore_permutation(int n, int w, int r) { N = n; ans.resize(n); add(0, n-1); // cout << "\n"; compile_set(); ask(0, 0, n-1); 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...