# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
421566 | marcipan5000 | 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 <bits/stdc++.h>
using namespace std;
void create_circuit (int M, std::vector<int> A) {
int n=A.size();
vector<int> t[100001];
for (int i=0;i<n-1;i++) {
t[A[i]].push_back(A[i+1]);
}
t[A[n-1]].push_back(0);
t[0].push_back(A[0]);
vector<int> x,y,c;
int p=-1;
for (int i=0;i<=M;i++) {
if (t[i].size()==0) {
c.push_back(0);
}
if (t[i].size()==1) {
c.push_back(t[i][0]);
}
if (t[i].size()==2) {
c.push_back(p);
x.push_back(t[i][0]);
y.push_back(t[i][1]);
p--;
}
if (t[i].size()==3) {
c.push_back(p);
x.push_back(p-1);
y.push_back(p-2);
x.push_back(t[i][0]);
y.push_back(t[i][1]);
x.push_back(p);
y.push_back(t[i][2]);
p=p-3;
}
if (t[i].size()==4) {
c.push_back(p);
x.push_back(p-1);
y.push_back(p-2);
x.push_back(t[i][0]);
y.push_back(t[i][2]);
x.push_back(t[i][1]);
y.push_back(t[i][3]);
p=p-3;
}
}
answer(c,x,y);
}