# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
954858 | Trisanu_Das | Mechanical Doll (IOI18_doll) | C++17 | 115 ms | 17620 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>
std::vector < int > X,Y,C,nx[100005];
void build(int stt,std::vector < int > tar){
X.push_back(0);
Y.push_back(0);
std::vector < int > G[2];
int i,j,k;
for(i=0;i<(int)tar.size();++i){
G[i&1].push_back(tar[i]);
}
if((int)tar.size()&1){
G[1].push_back(tar.back());
G[0].back()=-stt-1;
}
for(i=0;i<2;++i){
int *T=(i?&Y[stt]:&X[stt]);
if((int)G[i].size()==1)
*T=G[i][0];
else{
*T=-(int)X.size()-1;
build((int)X.size(),G[i]);
}
}
}
void create_circuit(int M, std::vector<int> A) {
C.resize(M+1);
int i,j,k;
for(i=0;i<(int)A.size();++i){
nx[A[i]].push_back(i==((int)A.size()-1)?0:A[i+1]);
}
C[0]=A[0];
X.clear();
Y.clear();
for(i=1;i<=M;++i){
if(nx[i].size()==0)
C[i]=i;
else if(nx[i].size()==1)
C[i]=nx[i][0];
else{
C[i]=-(int)X.size()-1;
build((int)X.size(),nx[i]);
}
}
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... |