Submission #308535

#TimeUsernameProblemLanguageResultExecution timeMemory
308535talant117408Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms512 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair <int, int> pii; #define precision(n) fixed << setprecision(n) #define pb push_back #define ub upper_bound #define lb lower_bound #define mp make_pair #define eps (double)1e-9 #define PI 2*acos(0.0) #define endl "\n" #define sz(v) int((v).size()) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); vector <int> per; map <pii, vector <int>> which, which2; void insertit(int l, int r, int n){ if(l == r) return; int mid = (l+r) >> 1, i; string in = ""; for(i = 0; i < n; i++) in += "1"; for(i = l; i <= r; i++) in[i] = '0'; for(i = l; i <= mid; i++){ in[i] = '1'; add_element(in); in[i] = '0'; } insertit(l, mid, n); insertit(mid+1, r, n); } void find(int l, int r, int n, vector <int> v){ if(l == r){ per[v[0]] = l; return; } int mid = (l+r) >> 1, i; string in = ""; for(i = 0; i < n; i++) in += "1"; for(auto to : v) in[to] = '0'; vector <int> lll, rrr; for(auto to : v){ in[to] = '1'; (check_element(in) ? lll : rrr).pb(to); in[to] = '0'; } find(l, mid, n, lll); find(mid+1, r, n, rrr); } vector<int> restore_permutation(int n, int w, int r) { per.resize(n, -1); vector <int> v(n); iota(all(v), 0); insertit(0, n-1, n); compile_set(); find(0, n-1, n, v); return per; }
#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...