Submission #541978

#TimeUsernameProblemLanguageResultExecution timeMemory
541978sliviuMechanical Doll (IOI18_doll)C++17
66.60 / 100
136 ms10052 KiB
#include <bits/stdc++.h> #include "doll.h" using namespace std; void create_circuit(int m, vector<int> a) { if (!(a.size() & 1)) a.emplace_back(-1); a.emplace_back(0); int n = a.size(), p = 1, k = 1; vector<int> c(m + 1, -1), x(400001), y(400001), parity(400001); while (p < n) p *= 2; function<int(int, int)> Build = [&](int left, int right) { if (left == right) return 0; if (right < p - n) return -1; int m = (left + right) / 2, cur = k++; x[cur - 1] = Build(left, m), y[cur - 1] = Build(m + 1, right); return -cur; }; Build(0, p - 1); for (int i = 0; i < n; ++i) { int cur = -1; while (cur) { int& next = !parity[-cur - 1] ? x[-cur - 1] : y[-cur - 1]; parity[-cur - 1] ^= 1; cur = next; if (!next) next = a[i]; } } x.resize(k), y.resize(k); answer(c, x, y); }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...