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 <bits/stdc++.h>
using namespace std;
#include "doll.h"
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mt make_tuple
#define x first
#define y second
const int MAX = 1e9;
vector<int> x, y, arr;
int solve(vector<int> idx) {
assert(idx.size());
if (idx.size() == 1) {
if (idx[0] >= MAX / 2) {
return idx[0] - MAX;
}
return idx[0] == (int)arr.size() ? 0 : arr[idx[0]];
}
x.push_back(0), y.push_back(0);
int v = -(int)x.size();
vector<int> lef, rig;
if (idx.size() % 2) {
idx.insert(idx.begin(), MAX + v);
}
for (int i = 0; i < (int)idx.size(); ++i) {
(i % 2 ? rig : lef).push_back(idx[i]);
}
assert(0 <= -1 - v && -1 - v < (int)x.size());
assert(0 <= -1 - v && -1 - v < (int)y.size());
int a = solve(lef), b = solve(rig);
x[-1 - v] = a;
y[-1 - v] = b;
return v;
}
void create_circuit(int m, vector<int> a) {
arr = a;
vector<int> c(m + 1, -1), idx((int)a.size() + 1);
iota(all(idx), 0);
int root = solve(idx);
assert(root == -1);
// cout << "===" << endl;
// for (int e : c) {
// cout << e << " ";
// }
// cout << endl;
// for (int e : x) {
// cout << e << " ";
// }
// cout << endl;
// for (int e : y) {
// cout << e << " ";
// }
// cout << endl;
answer(c, x, y);
}
#ifdef LC
#include "grader.cpp"
#endif
# | 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... |