Submission #585942

#TimeUsernameProblemLanguageResultExecution timeMemory
585942VanillaMechanical Doll (IOI18_doll)C++17
100 / 100
137 ms13636 KiB
#include <bits/stdc++.h> #include "doll.h" using namespace std; const int maxn = 2e5 + 2; int state [maxn * 2]; vector<int> x(2 * maxn), y(2 * maxn); int n, k, depth, ct; int dfs(int l, int r) { if (l >= n) return -1; if (r - l > 1) { int mid = (l + r) / 2, u = ct++; y[u] = dfs(l, mid); x[u] = dfs(mid, r); return -u-1; } return 1; } void create_circuit(int m, vector<int> a) { a.push_back(0); n = a.size(); vector<int> c(m + 1, -1); for (int i = 0; i < 30; i++){ if ((1 << i) >= n) { depth = i; break; } } k = (1 << depth); dfs(0, k); for (int i: a) { int node = 0; while (node >= 0) { int &next = state[node] ? y[node]: x[node]; state[node]^=1; if (next >= 0) next = i, node = -1; node = -next-1; } } x.resize(ct); y.resize(ct); 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...