Submission #299849

#TimeUsernameProblemLanguageResultExecution timeMemory
299849MatheusLealVUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms544 KiB
#include <bits/stdc++.h> #include "messy.h" #define pb push_back using namespace std; std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count()); #define all(x) begin(x), end(x) int n; vector<int> ans; void add(int ini, int fim){ if(fim==ini)return; int mid = (ini + fim)/2; string curr; for(int i = 0; i < n; i++){ if(ini <= i and i <= fim) curr.pb('1'); else curr.pb('0'); } for(int i = ini; i <= mid; i++){ curr[i] = '0'; // cout<<"add "<<curr<<"\n"; add_element(curr); curr[i]='1'; } add(ini, mid), add(mid+1, fim); } void solve(int ini, int fim, vector<int> caras){ if(ini == fim){ ans[caras[0]]=ini; return; } int mid = (ini+fim)/2; string curr; for(int i = 0; i < n; i++){ if(binary_search(all(caras), i)) curr.pb('1'); else curr.pb('0'); } vector<int> L, R; for(auto i: caras){ curr[i]='0'; // cout<<"query "<<curr<<"\n"; if(check_element(curr)) L.pb(i); else R.pb(i); curr[i] = '1'; } solve(ini,mid,L), solve(mid+1, fim, R); } vector<int> restore_permutation(int n_, int w, int r) { n=n_; ans.resize(n); vector<int> caras; for(int i = 0; i<n;i++)caras.pb(i); add(0,n-1); compile_set(); solve(0,n-1,caras); // for(auto w: ans)cout<<w<<" "; // cout<<"\n"; 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...