#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> edges[1005];
int dp[1005];
vector<bool> used;
void dfs(int u, int d=0){
dp[u] = d;
used[u] = true;
for(auto v:edges[u]){
if(used[v])continue;
dfs(v,d+1);
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for(int i=0;i<n-1;i++){
edges[u[i]].push_back(v[i]);
edges[v[i]].push_back(u[i]);
}
int mm=-1;
for(int i=0;i<n;i++){
if(edges[i].size() > 2)return u;
if(edges[i].size() == 1)mm = i;
}if(mm == -1)return u;
used.assign(n,0);
dfs(mm);
vector<int> ans(n);
for(int i=0;i<n;i++)ans[i] = dp[i];
return ans;
}
/*
1
5 10
0 1
1 2
2 3
3 4
3
1 3 121
1 4 121
0 1 122
*/
int find_next_station(int s, int t, vector<int> c) {
if(s <= t)return s+1;
else return s-1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Invalid length of array as the response of 'label'. scenario=1, n=3, len=2 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
392 KB |
Invalid length of array as the response of 'label'. scenario=0, n=996, len=995 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Invalid length of array as the response of 'label'. scenario=1, n=997, len=996 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
400 KB |
Invalid length of array as the response of 'label'. scenario=1, n=2, len=1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
0 ms |
0 KB |
Execution failed because of sandbox error |
2 |
Halted |
0 ms |
0 KB |
- |