Submission #1045098

#TimeUsernameProblemLanguageResultExecution timeMemory
1045098woodMechanical Doll (IOI18_doll)C++17
6 / 100
42 ms11208 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; #define pb push_back void create_circuit(int M, std::vector<int> A) { int N = A.size(); vector<int> adj[M]; for(int i = 0; i<N; i++){ if(i<N-1) adj[A[i]-1].pb(A[i+1]); else adj[A[i]-1].pb(0); } vector<int> res(M+1), x, y; int switchcnt = 0; res[0] = A[0]; for(int i = 0; i<M; i++){ if(adj[i].size()==1) res[i+1] = adj[i][0]; if(adj[i].size()==2){ switchcnt++; res[i+1] = -switchcnt; x.pb(adj[i][0]); y.pb(adj[i][1]); } if(adj[i].size()>2){ switchcnt++; res[i+1] = -switchcnt; switchcnt++; x.pb(-switchcnt); switchcnt++; y.pb(-switchcnt); x.pb(adj[i][0]); if(adj[i].size()==3) { y.pb(-switchcnt+2); x.pb(adj[i][1]); y.pb(adj[i][2]); } else{ y.pb(adj[i][1]); x.pb(adj[i][2]); y.pb(adj[i][3]); } } } answer(res,x,y); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...