#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 + 23;
vector<int> g[MAXN];
vector<int> labels;
int cnt = 0;
void dfs(int v, int p = -1) {
labels[v] = cnt++;
for (auto i : g[v]) if (i != p) dfs(i, v);
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
// cout << "learn" << endl;
for (int i = 0; i < n; i++) g[i].clear();
labels.clear();
cnt = 0;
for (int i = 0; i < n; i++) labels.push_back(0);
for (int i = 0; i < n - 1; i++) {
g[u[i]].push_back(v[i]), g[v[i]].push_back(u[i]);
}
for (int i = 0; i < n; i++) if (g[i].size() == 1) {
dfs(i);
break;
}
// assert(labels.size() == n);
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
if (s < t) return s + 1;
return s - 1;
}
/*
int main() {
for (auto i : label(3, 8, {0, 1}, {1, 2})) cout << i << endl;
return 0;
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
523 ms |
516 KB |
Output is correct |
2 |
Correct |
521 ms |
520 KB |
Output is correct |
3 |
Correct |
924 ms |
456 KB |
Output is correct |
4 |
Correct |
665 ms |
400 KB |
Output is correct |
5 |
Correct |
568 ms |
400 KB |
Output is correct |
6 |
Correct |
508 ms |
528 KB |
Output is correct |
7 |
Correct |
450 ms |
500 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
6 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
476 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
453 ms |
548 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
586 ms |
528 KB |
Output is correct |
2 |
Correct |
415 ms |
504 KB |
Output is correct |
3 |
Correct |
868 ms |
400 KB |
Output is correct |
4 |
Correct |
660 ms |
512 KB |
Output is correct |
5 |
Correct |
573 ms |
512 KB |
Output is correct |
6 |
Correct |
454 ms |
528 KB |
Output is correct |
7 |
Correct |
489 ms |
584 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
5 ms |
468 KB |
Output is correct |
10 |
Correct |
3 ms |
468 KB |
Output is correct |
11 |
Incorrect |
640 ms |
400 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
856 ms |
504 KB |
Output is correct |
2 |
Correct |
635 ms |
564 KB |
Output is correct |
3 |
Correct |
629 ms |
508 KB |
Output is correct |
4 |
Correct |
3 ms |
476 KB |
Output is correct |
5 |
Correct |
4 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Incorrect |
592 ms |
528 KB |
Wrong query response. |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
636 ms |
500 KB |
Output is correct |
2 |
Correct |
455 ms |
516 KB |
Output is correct |
3 |
Correct |
946 ms |
400 KB |
Output is correct |
4 |
Correct |
703 ms |
512 KB |
Output is correct |
5 |
Correct |
646 ms |
528 KB |
Output is correct |
6 |
Correct |
465 ms |
500 KB |
Output is correct |
7 |
Correct |
461 ms |
524 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
4 ms |
420 KB |
Output is correct |
10 |
Correct |
3 ms |
448 KB |
Output is correct |
11 |
Incorrect |
562 ms |
520 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |