This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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]);
}
int root = 0;
for(int i=0;i<n;i++){
if(tr[i].size() == 1){
root = i;
break;
}
}
dfs(root,-1);
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |