#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1000;
int degree[N];
vector<int> g[N], lbl;
void dfs(int u, int p, int l) {
lbl[u] = l;
for (int v : g[u]) {
if (v == p) {
continue;
}
dfs(v, u, l+1);
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
lbl = vector<int>(n);
for (int i=0 ; i<n ; i++) {
degree[i] = 0;
g[i].clear();
}
for (int i=0 ; i<n-1 ; i++) {
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
degree[u[i]]++;
degree[v[i]]++;
}
for (int i=0 ; i<n ; i++) {
if (degree[i] == 1) {
dfs(i, -1, 0);
break;
}
}
return lbl;
}
int find_next_station(int s, int t, vector<int> c) {
return s < t ? s+1 : s-1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
361 ms |
684 KB |
Output is correct |
2 |
Correct |
289 ms |
684 KB |
Output is correct |
3 |
Correct |
608 ms |
684 KB |
Output is correct |
4 |
Correct |
443 ms |
712 KB |
Output is correct |
5 |
Correct |
360 ms |
684 KB |
Output is correct |
6 |
Correct |
306 ms |
940 KB |
Output is correct |
7 |
Correct |
296 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
776 KB |
Output is correct |
10 |
Correct |
0 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Invalid labels (duplicates values). scenario=0, label=10 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
320 ms |
684 KB |
Output is correct |
2 |
Correct |
284 ms |
688 KB |
Output is correct |
3 |
Correct |
551 ms |
684 KB |
Output is correct |
4 |
Correct |
451 ms |
684 KB |
Output is correct |
5 |
Correct |
404 ms |
684 KB |
Output is correct |
6 |
Correct |
306 ms |
688 KB |
Output is correct |
7 |
Correct |
328 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
772 KB |
Output is correct |
9 |
Correct |
3 ms |
776 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Incorrect |
1 ms |
344 KB |
Invalid labels (duplicates values). scenario=1, label=2 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
607 ms |
684 KB |
Output is correct |
2 |
Correct |
425 ms |
684 KB |
Output is correct |
3 |
Correct |
367 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
776 KB |
Output is correct |
5 |
Correct |
2 ms |
768 KB |
Output is correct |
6 |
Correct |
1 ms |
768 KB |
Output is correct |
7 |
Incorrect |
1 ms |
344 KB |
Invalid labels (duplicates values). scenario=0, label=2 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
364 ms |
684 KB |
Output is correct |
2 |
Correct |
296 ms |
684 KB |
Output is correct |
3 |
Correct |
586 ms |
684 KB |
Output is correct |
4 |
Correct |
428 ms |
684 KB |
Output is correct |
5 |
Correct |
401 ms |
684 KB |
Output is correct |
6 |
Correct |
298 ms |
684 KB |
Output is correct |
7 |
Correct |
309 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
764 KB |
Output is correct |
9 |
Correct |
2 ms |
764 KB |
Output is correct |
10 |
Correct |
0 ms |
764 KB |
Output is correct |
11 |
Incorrect |
3 ms |
600 KB |
Invalid labels (duplicates values). scenario=0, label=10 |
12 |
Halted |
0 ms |
0 KB |
- |