Submission #781037

#TimeUsernameProblemLanguageResultExecution timeMemory
781037jasminStations (IOI20_stations)C++17
5 / 100
789 ms640 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; void dfs(int v, int p, int ind, vector<vector<int> >& adi, vector<int>& lab){ lab[v]=ind; for(auto u: adi[v]){ if(u==p) continue; dfs(u, v, ind+1, adi, lab); } } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<vector<int> > adi(n); for(int i=0; i<n-1; i++){ adi[v[i]].push_back(u[i]); adi[u[i]].push_back(v[i]); } int endpoint=-1; for(int i=0; i<n; i++){ if(adi[i].size()==1){ endpoint=i; break; } } vector<int> lab(n, -1); dfs(endpoint, -1, 0, adi, lab); return lab; } int find_next_station(int s, int t, vector<int> c) { if(c.size()==1){ return c[0]; } if(t<=c[0]){ return c[0]; } return c[1]; }
#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...