# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
999335 | 2024-06-15T10:13:32 Z | MarwenElarbi | 자동 인형 (IOI18_doll) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define ll long long #define pb push_back #define ii pair<int,int> const int nax=2e5+5; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); vector<int> adj[nax]; int vis[nax]; int counter=0; void create_circuit(int M, std::vector<int> A) { vector<int> X,Y; vector<int> C(M+1); C[0]=A[0]; int N = A.size(); A.pb(0); for (int i = 0; i < N; ++i) { adj[A[i]].pb(A[i+1]); } for (int i = 0; i < N; ++i) { if(vis[A[i]]>0) continue; vis[A[i]]=1; if(adj[A[i]].size()==1){ C[A[i]]=A[i+1]; continue; } X.emplace_back(); Y.emplace_back(); C[A[i]]=-(int)(X.size()); for (int j = 0; j < adj[A[i]].size()-2; ++j) { cout <<A[i]<<" "<<j<<endl; X.back()=adj[A[i]][j]; Y.back()=-((int)X.size()+1); X.emplace_back(); Y.emplace_back(); } X.back()=adj[A[i]][adj[A[i]].size()-2]; Y.back()=adj[A[i]][adj[A[i]].size()-1]; } /*for (int i = 0; i < M+1; ++i) { cout << C[i]<<" "; }cout <<endl; for (int i = 0; i < X.size(); ++i) { cout <<X[i]<<" "; }cout <<endl; for (int i = 0; i < Y.size(); ++i) { cout <<Y[i]<<" "; }cout <<endl;*/ answer(C, X, Y); }