# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
414348 | DBPhoenix | Mechanical Doll (IOI18_doll) | C++17 | 131 ms | 19872 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 "doll.h"
#include <bits/stdc++.h>
using namespace std;
struct Tree {
int pointer = 1;
vector<int> nodes = {0};
};
int switches = 0;
Tree tree[200001];
void insert(int i, int value)
{
if (tree[i].pointer == 1) {
tree[i].nodes.push_back(value);
tree[i].pointer++;
return;
}
if (tree[i].nodes[tree[i].pointer / 2] > -1) {
tree[i].nodes.push_back(tree[i].nodes[tree[i].pointer / 2]);
tree[i].nodes[tree[i].pointer / 2] = -(++switches);
tree[i].pointer++;
}
tree[i].nodes.push_back(value);
tree[i].pointer++;
}
void create_circuit(int M, std::vector<int> A) {
int N = A.size();
int prev = 0;
for (int a : A)
{
insert(prev, a);
prev = a;
}
insert(prev, 0);
vector<int> C(M + 1);
for (int i = 0; i <= M; ++i)
{
if (tree[i].nodes.size() < 2)
C[i] = 1;
else
C[i] = tree[i].nodes[1];
}
vector<int> X(switches);
vector<int> Y(switches);
for (int i = 0; i <= M; i++)
{
for (int j = 1; true; j++)
if (tree[i].nodes[j] > -1) break;
else
{
X[-tree[i].nodes[j] - 1] = tree[i].nodes[j * 2];
Y[-tree[i].nodes[j] - 1] = tree[i].nodes[j * 2 + 1];
}
}
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... |