#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
std::vector<int> labels(n);
vector < int > adj[n + 7];
for ( int i = 0; i < n - 1; i++ ) {
int x = u[i], y = v[i];
adj[x].push_back(y);
adj[y].push_back(x);
}
vector < int > used(n + 1);
int rt = -1;
for ( int i = 0; i < n; i++ ) {
if ( adj[i].size() == 1 && !used[i] ) {
rt = i;
break;
}
}
int x = rt, num = 0;
while ( 1 ) {
labels[x] = num++;
used[x] = 1;
int ok = 1;
for ( auto y: adj[x] ) {
if ( !used[y] ) {
x = y;
ok = 0;
break;
}
}
if ( ok ) {
break;
}
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if ( c.size() == 1 ) {
return c[0];
}
if ( s < t ) {
return c[1];
}
return c[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
665 ms |
756 KB |
Output is correct |
2 |
Correct |
506 ms |
792 KB |
Output is correct |
3 |
Correct |
1023 ms |
748 KB |
Output is correct |
4 |
Correct |
655 ms |
764 KB |
Output is correct |
5 |
Correct |
647 ms |
996 KB |
Output is correct |
6 |
Correct |
536 ms |
736 KB |
Output is correct |
7 |
Correct |
460 ms |
796 KB |
Output is correct |
8 |
Correct |
3 ms |
908 KB |
Output is correct |
9 |
Correct |
4 ms |
868 KB |
Output is correct |
10 |
Correct |
2 ms |
756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
364 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 |
756 KB |
Output is correct |
2 |
Correct |
505 ms |
756 KB |
Output is correct |
3 |
Correct |
953 ms |
868 KB |
Output is correct |
4 |
Correct |
682 ms |
868 KB |
Output is correct |
5 |
Correct |
649 ms |
736 KB |
Output is correct |
6 |
Correct |
425 ms |
892 KB |
Output is correct |
7 |
Correct |
521 ms |
756 KB |
Output is correct |
8 |
Correct |
3 ms |
736 KB |
Output is correct |
9 |
Correct |
4 ms |
756 KB |
Output is correct |
10 |
Correct |
2 ms |
736 KB |
Output is correct |
11 |
Incorrect |
1 ms |
364 KB |
Invalid labels (duplicates values). scenario=1, label=0 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
998 ms |
884 KB |
Output is correct |
2 |
Correct |
705 ms |
868 KB |
Output is correct |
3 |
Correct |
694 ms |
868 KB |
Output is correct |
4 |
Correct |
2 ms |
756 KB |
Output is correct |
5 |
Correct |
4 ms |
736 KB |
Output is correct |
6 |
Correct |
1 ms |
736 KB |
Output is correct |
7 |
Incorrect |
1 ms |
364 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
710 ms |
756 KB |
Output is correct |
2 |
Correct |
434 ms |
844 KB |
Output is correct |
3 |
Correct |
1000 ms |
868 KB |
Output is correct |
4 |
Correct |
670 ms |
868 KB |
Output is correct |
5 |
Correct |
690 ms |
756 KB |
Output is correct |
6 |
Correct |
565 ms |
756 KB |
Output is correct |
7 |
Correct |
530 ms |
796 KB |
Output is correct |
8 |
Correct |
3 ms |
756 KB |
Output is correct |
9 |
Correct |
4 ms |
756 KB |
Output is correct |
10 |
Correct |
1 ms |
756 KB |
Output is correct |
11 |
Incorrect |
5 ms |
364 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
12 |
Halted |
0 ms |
0 KB |
- |