# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
300939 | TMJN | Mechanical Doll (IOI18_doll) | C++17 | 2 ms | 332 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;
void create_circuit(int M,vector<int>A){
assert(false);
vector<int>X,Y,C;
X=Y=vector<int>(400000,0);
C=vector<int>(M+1,0);
vector<vector<int>>K(M+1);
for(int i=1;i<=M;i++){
C[i]=-i*3;
X[i*3-1]=-i*3-1;
Y[i*3-1]=-i*3-2;
X[i*3]=-i*3;
Y[i*3]=-i*3;
X[i*3+1]=-i*3;
Y[i*3+1]=-i*3;
}
C[0]=A[0];
A.push_back(0);
for(int i=0;i<A.size()-1;i++){
K[A[i]].push_back(A[i+1]);
}
for(int i=1;i<=M;i++){
if(K[i].size()==0)continue;
if(K[i].size()==1){
C[i]=K[i][0];
}
if(K[i].size()==2){
X[i*3-1]=K[i][0];
Y[i*3-1]=K[i][1];
}
if(K[i].size()==3){
X[i*3+1]=K[i][0];
Y[i*3]=K[i][1];
Y[i*3+1]=K[i][2];
}
if(K[i].size()==4){
X[i*3]=K[i][0];
X[i*3+1]=K[i][1];
Y[i*3]=K[i][2];
Y[i*3+1]=K[i][3];
}
}
A.pop_back();
vector<bool>B(400000,false);
int p=0;
vector<int>T;
do{
if(p>=0){
if(p)T.push_back(p);
p=C[p];
}
else{
if(B[-p-1]){
p=Y[-p-1];
}
else{
p=X[-p-1];
}
B[-p-1]=!B[-p-1];
}
}while(p);
assert(A==T);
bool f=false;
for(int i=0;i<400000;i++){
f|=B[i];
}
assert(!f);
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... |