Submission #403137

#TimeUsernameProblemLanguageResultExecution timeMemory
403137AmineTrabelsiStations (IOI20_stations)C++14
0 / 100
3048 ms2097156 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int Mx = 1001; vector<int> labels; vector<int> tr[Mx]; void dfs(int node,int par){ for(auto i:tr[node]){ if(i != par){ labels[i] = labels[node]+1; dfs(i,node); } } } vector<int> label(int n, int k, vector<int> u, vector<int> v) { labels.assign(n,0); for (int i = 0; i < n-1; i++) { tr[u[i]].push_back(v[i]); tr[v[i]].push_back(u[i]); } for(int i=0;i<n;i++){ if(tr[i].size() == 1){ dfs(i,i); break; } } return labels; } int find_next_station(int s, int t, vector<int> c) { int ans = -1; if(t > s){ for(auto i:c){ ans = max(ans,i); } }else{ ans = 1e9+7; for(auto i:c){ ans = min(ans,i); } } return ans; }
#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...