#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) {
if(t <= s){
return *min_element(c.begin(),c.end());
}
return *max_element(c.begin(),c.end());
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1445 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3076 ms |
388 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1487 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
996 ms |
400 KB |
Output is correct |
2 |
Runtime error |
1137 ms |
2097156 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2673 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |