#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() > 2){
head = i;
}
}
dist[head] = 0;
int cnt = 1;
for(int i:paths[head]){
dfs(i,cnt*1000);
cnt ++;
}
// 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 (c.size() == 1) return c[0];
if((t/1000) != (s/1000))return c[0];
if(t>s)return c[1];
return c[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=2004 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
344 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1007 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
346 ms |
684 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
580 ms |
684 KB |
Output is correct |
2 |
Incorrect |
427 ms |
684 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
364 ms |
688 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |