이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
struct node {
node *left, *right;
int num, level, idx;
};
int N, k = 1;
vector< pair<int, int> > tmpx, tmpy;
node* build(int num, int level, int idx, const vector<int>& A) {
if ((1 << level) == k) {
return new node{nullptr, nullptr, (idx == k - 1 ? 0 : (idx < N - 1 ? A[idx + 1] : -1)), level, idx};
}
node* left = build(num * 2, level + 1, idx, A);
node* right = build(num * 2 - 1, level + 1, idx + (1 << level), A);
return new node{left, right, num, level, idx};
}
void output(node* cur) {
if ((1 << cur->level) == k) {
return;
}
tmpx.push_back({cur->num, cur->left->num});
tmpy.push_back({cur->num, cur->right->num});
output(cur->left);
output(cur->right);
}
void create_circuit(int M, vector<int> A) {
N = (int) A.size();
while (k < N) {
k *= 2;
}
cout << k << '\n';
node* root = build(-1, 0, 0, A);
vector<int> C(M + 1, -1);
C[0] = A[0];
output(root);
sort(tmpx.rbegin(), tmpx.rend());
sort(tmpy.rbegin(), tmpy.rend());
vector<int> X, Y;
for (auto& p : tmpx) {
X.push_back(p.second);
}
for (auto& p : tmpy) {
Y.push_back(p.second);
}
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... |