#include "stations.h"
#include <vector>
#include <queue>
using namespace std;
vector<vector<int>> paths(1001);
vector<int> dist(1001,-1);
void dfs(int pos,int len){
if(dist[pos] != -1)return;
dist[pos] = 0;
for(int i:paths[pos])dfs(i,len+1);
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
std::vector<int> labels(n);
paths = vector<vector<int>>(1001);
dist = vector<int>(1001,-1);
for(int i = 0;i<n-1;i++){
paths[u[i]].push_back(v[i]);
paths[v[i]].push_back(u[i]);
}
dfs(0,0);
int head = 0,len = 0;
for (int i = 0; i < n; i++) {
if(len<dist[i])head = i;
len = max(len,dist[i]);
}
dist = vector<int>(1001,-1);
dfs(head,0);
for (int i = 0; i < n; i++) {
labels[i] = dist[i];
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(s>t)return c[0];
return c[1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
596 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
596 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |