Submission #765988

#TimeUsernameProblemLanguageResultExecution timeMemory
765988SanguineChameleonUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
5 ms496 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; int n; string make1(int lt, int rt, int x) { string res; for (int i = 0; i < n; i++) { if (i != x && lt <= i && i <= rt) { res += "0"; } else { res += "1"; } } return res; } void solve1(int lt, int rt) { if (lt == rt) { return; } int mt = (lt + rt) / 2; for (int i = lt; i <= mt; i++) { add_element(make1(lt, rt, i)); } solve1(lt, mt); solve1(mt + 1, rt); } string make2(vector<int> cand, int x) { string res; for (int i = 0; i < n; i++) { if (i != x && find(cand.begin(), cand.end(), i) != cand.end()) { res += "0"; } else { res += "1"; } } return res; } vector<int> res; void solve2(int lt, int rt, vector<int> cand) { if (lt == rt) { res[cand[0]] = lt; return; } int mt = (lt + rt) / 2; vector<int> left; vector<int> right; for (auto x: cand) { if (check_element(make2(cand, x))) { left.push_back(x); } else { right.push_back(x); } } solve2(lt, mt, left); solve2(mt + 1, rt, right); } vector<int> restore_permutation(int _n, int w, int r) { n = _n; solve1(0, n - 1); compile_set(); vector<int> 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...