#include "stations.h"
#include <vector>
#include <queue>
#include <iostream>
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] = len;
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]);
}
int head = 0;
for (int i = 0; i < n; i++) {
if(paths[i].size() == 1){
head = i;
}
}
dfs(head,0);
// cerr << head << endl;
for (int i = 0; i < n; i++) {
labels[i] = dist[i];
// cerr << labels[i] << " ";
}
// cerr << endl;
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 |
348 ms |
684 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
344 KB |
Invalid labels (duplicates values). scenario=0, label=11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
405 ms |
684 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
649 ms |
684 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
341 ms |
684 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |