# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
115400 | dsjong | Mechanical Doll (IOI18_doll) | C++14 | 94 ms | 15140 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;
bool vis[100005];
int cnt[100005];
vector<int>adj[100005];
void create_circuit(int M, vector<int> A){
vector<int>C(M+1);
memset(vis,false,sizeof vis);
A.push_back(0);
int S=0;
C[0]=A[0];
for(int i=0;i<A.size()-1;i++){
cnt[A[i]]++;
adj[A[i]].push_back(A[i+1]);
if(cnt[A[i]]==2) S++;
}
vector<int>X(S),Y(S);
int cur=-1;
for(int i=0;i<A.size()-1;i++){
if(vis[A[i]]){
Y[-cur-1]=A[i+1];
X[-cur-1]=adj[A[i]][0];
C[A[i]]=cur--;
}
else C[A[i]]=A[i+1];
vis[A[i]]=true;
}
for(int i=1;i<=M;i++){
if(cnt[i]==0) C[i]=1;
}
/*cout<<C.size()<<endl;
for(int i:C) cout<<i<<" ";
cout<<endl;
cout<<X.size()<<endl;
for(int i:X) cout<<i<<" ";
cout<<endl;
cout<<Y.size()<<endl;
for(int i:Y) cout<<i<<" ";
cout<<endl;*/
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... |