Submission #425157

#TimeUsernameProblemLanguageResultExecution timeMemory
425157PbezzMechanical Doll (IOI18_doll)C++14
16 / 100
102 ms12120 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back typedef pair<ll,ll> pii; const ll MAXN = 2e5+5; const ll INF = 1e9+7; void create_circuit(int M, std::vector<int> A) { int n = A.size(),k,S=-1,i; vector<vector<int>>adj(M+5); std::vector<int> X, Y; std::vector<int> C(M + 1); C[0]=A[0]; for(i=0;i<n-1;i++){ //C[A[i]]=A[i+1]; adj[A[i]].pb(A[i+1]); } adj[A[n-1]].pb(0); for(i=1;i<=M;i++){ k=adj[i].size(); // cout<<i<<" #"<<k<<endl; if(k==1){ C[i]=adj[i][0]; }else if(k==2){ C[i]=S; X.pb(adj[i][0]); Y.pb(adj[i][1]); S--; }else if(k==3){ C[i]=S; X.pb(S-1); Y.pb(S-2); S--; X.pb(adj[i][0]); Y.pb(C[i]); S--; X.pb(adj[i][1]); Y.pb(adj[i][2]); S--; }else if(k==4){ C[i]=S; X.pb(S-1); Y.pb(S-2); S--; X.pb(adj[i][0]); Y.pb(adj[i][2]); S--; X.pb(adj[i][1]); Y.pb(adj[i][3]); S--; } } /* for(i=0;i<=M;i++)cout<<C[i]<<" "; cout<<endl; cout<<S<<endl; for(auto u:X)cout<<u<<" "; cout<<endl; for(auto u:Y)cout<<u<<" "; cout<<endl; */ answer(C, 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...