# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1197805 | MateiKing80 | Mechanical Doll (IOI18_doll) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
vector<int> ansX, ansY, ansLegit;
int maxx = 1;
void build(int loc, vector<int> a) {
if (a.size() % 2 == 1) {
a.push_back(-1);
for (int i = a.size() - 1; i; i --)
swap(a[i], a[i - 1]);
}
vector<int> l, r;
int pos = 0;
for (auto i : a) {
(pos ? r : l).push_back(i);
pos ^= 1;
}
if (l.size() == 1)
ansX[-loc - 1] = l[0];
else {
ansX[-loc - 1] = -(++ maxx);
build(-maxx, l);
}
if (r.size() == 1)
ansY[-loc - 1] = r[0];
else {
ansY[-loc - 1] = -(++ maxx);
build(-maxx, r);
}
}
void create_circuit(int m, vector<int> a) {
a.push_back(0);
ansLegit.resize(m + 1);
ansX.resize(10 * m);
ansY.resize(10 * m);
for (int i = 0; i <= m; i ++)
ansLegit[i] = -1;
build(-1, a);
ansX.resize(maxx);
ansY.resize(maxx);
answer(ansLegit, ansX, ansY);
}