# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
300949 | TMJN | Mechanical Doll (IOI18_doll) | C++17 | 7 ms | 6860 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;
static vector<int>X,Y,K;
static int c;
int dfs(int num,int dep){
if(K.size()-1<num+(1<<dep)){
return K[num];
}
else{
int t=c;
c++;
X[t]=dfs(num,dep+1);
Y[t]=dfs(num+(1<<dep),dep+1);
return -t-1;
}
}
void create_circuit(int M,vector<int>A) {
X=Y=vector<int>(400000,0);
K=A;
c=0;
for(int i=0;;i++){
if((1<<i)>K.size()){
while((1<<i)>K.size()){
K.push_back(-c-1);
c++;
}
K.back()=0;
c--;
break;
}
}
int cc=c;
int tt=dfs(0,0);
for(int i=0;i<cc;i++){
X[i]=-i-1;
Y[i]=tt;
}
vector<int>C(M+1,tt);
// while(!X.empty()&&X.back()==0xE869120){
// X.pop_back();
// Y.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... |