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;
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... |