Submission #1077658

#TimeUsernameProblemLanguageResultExecution timeMemory
1077658s_treeMechanical Doll (IOI18_doll)C++17
84 / 100
97 ms19104 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; const int N = 1e6; vector<int> x(N), y(N), c(N); vector<int> state(N); int nodecnt = 0, n, pw = 1; int build(int l, int r) { if (l >= r) return 0; if (r < pw - n) { return -1; } int mid = (l + r) / 2; int cur = ++nodecnt; x[cur - 1] = build(l, mid); y[cur - 1] = build(mid + 1, r); return -cur; } void ins(int i, int val) { if (state[-i]) { state[-i] ^= 1; if (y[-i - 1] == 0) { y[-i - 1] = val; } else { ins(y[-i - 1], val); } } else { state[-i] ^= 1; if (x[-i - 1] == 0) { x[-i - 1] = val; } else { ins(x[-i - 1], val); } } } void create_circuit(int M, std::vector<int> A) { pw = 1; n = A.size(); c = vector<int>(M + 1, -1); while (pw < n) { pw *= 2; } build(0, pw - 1); for (int i = 1; i < n; i++) { ins(-1, A[i]); } if (n % 2 == 1) ins(-1, -1); ins(-1, 0); c[0] = A[0]; x.resize(nodecnt); y.resize(nodecnt); 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...