#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<int> deg(n);
vector<vector<int>> adj(n);
for (int i = 0; i < n - 1; i++)
deg[u[i]]++, deg[v[i]]++, adj[u[i]].push_back(v[i]), adj[v[i]].push_back(u[i]);;
vector<int> labels(n);
if (*max_element(deg.begin(), deg.end()) <= 2) {
int r = min_element(deg.begin(), deg.end()) - deg.begin(), p = -1;
labels[r] = 0;
for (int i = 1; i < n; i++) {
if (~p) adj[r].erase(find(adj[r].begin(), adj[r].end(), p));
tie(r, p) = make_pair(adj[r][0], r);
labels[r] = i;
}
}
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
return s < t ? *max_element(c.begin(), c.end()) : *min_element(c.begin(), c.end());
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
578 ms |
784 KB |
Output is correct |
2 |
Correct |
555 ms |
768 KB |
Output is correct |
3 |
Correct |
1023 ms |
648 KB |
Output is correct |
4 |
Correct |
670 ms |
640 KB |
Output is correct |
5 |
Correct |
673 ms |
640 KB |
Output is correct |
6 |
Correct |
510 ms |
816 KB |
Output is correct |
7 |
Correct |
486 ms |
768 KB |
Output is correct |
8 |
Correct |
3 ms |
640 KB |
Output is correct |
9 |
Correct |
6 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
384 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
533 ms |
800 KB |
Output is correct |
2 |
Correct |
501 ms |
768 KB |
Output is correct |
3 |
Correct |
870 ms |
784 KB |
Output is correct |
4 |
Correct |
736 ms |
644 KB |
Output is correct |
5 |
Correct |
584 ms |
640 KB |
Output is correct |
6 |
Correct |
535 ms |
820 KB |
Output is correct |
7 |
Correct |
517 ms |
824 KB |
Output is correct |
8 |
Correct |
3 ms |
648 KB |
Output is correct |
9 |
Correct |
5 ms |
652 KB |
Output is correct |
10 |
Correct |
1 ms |
640 KB |
Output is correct |
11 |
Incorrect |
1 ms |
256 KB |
Invalid labels (duplicates values). scenario=1, label=0 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
966 ms |
772 KB |
Output is correct |
2 |
Correct |
673 ms |
648 KB |
Output is correct |
3 |
Correct |
726 ms |
644 KB |
Output is correct |
4 |
Correct |
3 ms |
652 KB |
Output is correct |
5 |
Correct |
5 ms |
640 KB |
Output is correct |
6 |
Correct |
2 ms |
648 KB |
Output is correct |
7 |
Incorrect |
1 ms |
256 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
697 ms |
768 KB |
Output is correct |
2 |
Correct |
535 ms |
816 KB |
Output is correct |
3 |
Correct |
1017 ms |
652 KB |
Output is correct |
4 |
Correct |
791 ms |
644 KB |
Output is correct |
5 |
Correct |
624 ms |
648 KB |
Output is correct |
6 |
Correct |
449 ms |
768 KB |
Output is correct |
7 |
Correct |
458 ms |
828 KB |
Output is correct |
8 |
Correct |
3 ms |
648 KB |
Output is correct |
9 |
Correct |
4 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
648 KB |
Output is correct |
11 |
Incorrect |
5 ms |
384 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
12 |
Halted |
0 ms |
0 KB |
- |