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"
#include <bits/stdc++.h>
using namespace std;
int BuildTree(const vector<int>& outs, vector<int>& x, vector<int>& y) {
if (outs.size() == 1) {
return outs[0];
}
vector<int> left, right;
for (int i = 0; i < (int) outs.size(); ++i) {
if (i % 2 == 0)
left.push_back(outs[i]);
else
right.push_back(outs[i]);
}
int id_left = BuildTree(left, x, y);
int id_right = BuildTree(right, x, y);
x.push_back(id_left);
y.push_back(id_right);
return -(int)x.size();
}
void create_circuit(int M, std::vector<int> A) {
int n = A.size();
vector<vector<int>> outs(M + 1);
outs[0].push_back(A[0]);
std::vector<int> C(M + 1);
vector<int> X, Y;
for (int i = 0; i < n; ++i) {
if (i + 1 < n)
outs[A[i]].push_back(A[i + 1]);
}
for (int i = 0; i < M + 1; ++i) {
if (!outs[i].empty())
C[i] = BuildTree(outs[i], X, Y);
}
answer(C, X, Y);
}
# | 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... |