Submission #478501

#TimeUsernameProblemLanguageResultExecution timeMemory
478501JovanBUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms460 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; const int N = 200; int soln[N+5]; void do_add(int n, int l, int r){ string qr = ""; for(int i=0; i<n; i++) qr += '1'; for(int i=l; i<=r; i++) qr[i] = '0'; int mid = (l+r)/2; for(int i=l; i<=mid; i++){ qr[i] = '1'; add_element(qr); qr[i] = '0'; } if(mid != l){ do_add(n, l, mid); do_add(n, mid+1, r); } } void do_find(int n, int l, int r, vector <int> where){ if(l == r){ soln[where[0]] = l; return; } string qr = ""; for(int i=0; i<n; i++) qr += '1'; for(auto c : where) qr[c] = '0'; int mid = (l+r)/2; vector <int> v1, v2; for(auto c : where){ qr[c] = '1'; if(check_element(qr)) v1.push_back(c); else v2.push_back(c); qr[c] = '0'; } do_find(n, l, mid, v1); do_find(n, mid+1, r, v2); } std::vector<int> restore_permutation(int n, int w, int r) { do_add(n, 0, n - 1); compile_set(); vector <int> svi; for(int i=0; i<n; i++) svi.push_back(i); do_find(n, 0, n - 1, svi); vector <int> sln; for(int i=0; i<n; i++) sln.push_back(soln[i]); return sln; }
#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...