제출 #299850

#제출 시각아이디문제언어결과실행 시간메모리
299850MatheusLealVUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms640 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'; 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'; 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); 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...