Submission #785619

#TimeUsernameProblemLanguageResultExecution timeMemory
785619MODDIUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
4 ms504 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair typedef long long ll; typedef pair<long long, long long> pll; typedef pair<int,int> pii; typedef vector<long long> vl; typedef vector<int> vi; int n; string create1(int l, int r, int x){ string ret; for(int i = 0; i < n; i++){ if(i != x && l <= i && i <= r) ret+="0"; else ret+="1"; } return ret; } string create2(vi cand, int x){ string ret; for(int i = 0; i < n; i++){ if(i != x && find(cand.begin(), cand.end(), i) != cand.end()) ret += "0"; else ret += "1"; } return ret; } void solve1(int l, int r){ if(l == r) return; int mid = (l + r) / 2; for(int i = l; i <= mid; i++){ add_element(create1(l, r, i)); } solve1(l, mid); solve1(mid+1, r); } vi res; void solve2(int l, int r, vi cand){ if(l == r){ res[cand[0]] = l; return; } int mid = (l + r) / 2; vi left, right; for(auto x : cand){ if(check_element(create2(cand, x))) left.pb(x); else right.pb(x); } solve2(l, mid, left); solve2(mid+1, r, right); } vi restore_permutation(int _n, int w, int r){ n = _n; solve1(0, n-1); compile_set(); vi cand(n); for(int i = 0; i < n; i++) cand[i] = i; res.resize(n); solve2(0, n-1, cand); return res; }
#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...