# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
434305 | 2021-06-20T22:10:36 Z | Play_Erwan | Stations (IOI20_stations) | C++14 | 0 ms | 0 KB |
#include "stations.h" #include <vector> #include<bits/stdc++.h> using namespace std; #define pb push_back #define F first #define S second int aqui,cont; vector<int> adj[1000],l; bool mk[1000]; void dfs(int x){ mk[x]=1; l[x]=cont; cont++; for(auto y:adj[x])if(!mk[y])dfs(y); } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { cont=0; for(int i=0;i<n;i++){adj[i].clear(); mk[i]=0;} label.clear(); for (int i = 0; i < n-1; i++) { adj[u[i]].pb(v[i]); adj[v[i]].pb(u[i]); } for(int i=0;i<n;i++)l.pb(0); for(int i=0;i<n;i++)if(adj[i].size()==1){aqui=i; break;} dfs(aqui); // for(auto x:l)cout<<x<<" "; // cout<<"\n"; return l; } int find_next_station(int s, int t, std::vector<int> c) { if(t>s)return c[c.size()-1]; else return c[0]; }