# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
560693 | tfg | Mechanical Doll (IOI18_doll) | C++17 | 145 ms | 13824 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "doll.h"
std::vector<int> X, Y;
int solve(std::vector<int> A) {
int id = (int) X.size();
X.push_back(-id-1), Y.push_back(-id-1);
int n = (int) A.size();
if(n == 1) {
Y[id] = A[0];
} else if(n == 2) {
X[id] = A[0];
Y[id] = A[1];
} else {
if(n % 2) {
n++;
A.insert(A.end() - 1, -id-1);
}
std::vector<int> parts[2];
for(int i = 0; i < n; i++) {
parts[i%2].push_back(A[i]);
}
X[id] = solve(parts[0]);
Y[id] = solve(parts[1]);
}
return -id-1;
}
void create_circuit(int M, std::vector<int> A) {
int N = A.size();
std::vector<int> C(M + 1, -1);
C[0] = A[0];
A.erase(A.begin());
A.push_back(0);
solve(A);
answer(C, X, Y);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |