# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
286113 | NONAME | Mechanical Doll (IOI18_doll) | C++14 | 0 ms | 0 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 "grader.h"
const int MAX_M = (int)(1e5 + 500);
std::vector <int> res, X, Y;
std::vector <int> g[MAX_M];
void create_circuit (int m, std::vector <int> a) {
int n = (int)(a.size());
res.resize(n + 1);
res[0] = a[0];
for (int i = 0; i < n; ++i)
g[a[i]].push_back((i + 1 == n) ? 0 : a[i + 1]);
int cur = -1;
for (int i = 1; i <= m; ++i) {
if ((int)(g[i].size()) == 0)
res[i] = 0;
if ((int)(g[i].size()) == 1)
res[i] = g[i][0];
if ((int)(g[i].size()) == 2) {
res[i] = cur;
X.push_back(g[i][0]);
Y.push_back(g[i][1]);
--cur;
}
}
answer(res, X, Y);
}