# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
330480 | aquablitz11 | Mechanical Doll (IOI18_doll) | C++14 | 151 ms | 11868 KiB |
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>
#include "doll.h"
using namespace std;
const int INF = 2e9;
vector<int> C, X, Y;
int cnt = 0;
int get_switch(int x, int y) {
X.push_back(x);
Y.push_back(y);
return --cnt;
}
int create_tree(const vector<int> &v) {
if (v.size() == 1)
return v[0];
vector<int> vx, vy;
for (int i = 0; i < v.size(); ++i) {
if (i % 2 == 0)
vx.push_back(v[i]);
else
vy.push_back(v[i]);
}
int x = create_tree(vx);
int y = create_tree(vy);
return get_switch(x, y);
}
void create_circuit(int M, vector<int> A) {
int n = A.size();
int k = 0;
while ((1<<k) < n)
++k;
n = 1<<k;
vector<int> v(A.begin()+1, A.end());
v.resize(n, INF);
v[n-1] = 0;
int r = create_tree(v);
C = vector<int>(M+1, r);
C[0] = A[0];
for (auto &x: X) {
if (x == INF)
x = r;
}
for (auto &y: Y) {
if (y == INF)
y = r;
}
answer(C, X, Y);
}
Compilation message (stderr)
# | 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... |