이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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]);
}
outs[A[n - 1]].push_back(0);
for (int i = 0; i < M + 1; ++i) {
if (!outs[i].empty()) {
while (outs[i].size() & ((int) outs[i].size() - 1)) outs[i].push_back(0);
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... |