#include<stations.h>
#include<bits/stdc++.h>
using namespace std;
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
// create adjacency list
vector<int> adjacency_list[n] = {};
for (int i = 0; i < n-1; i++) {
int fnode = u[i]; int snode = v[i];
adjacency_list[fnode].push_back(snode); adjacency_list[snode].push_back(fnode);
}
// find origin
int origin;
for (int i = 0; i < n; i++) {
if (adjacency_list[i].size() == 1) {
origin = i;
break;
}
}
// create labels
vector<int> labels(n);
bool visited[n] {false};
int counter = 0;
int current_node = origin;
while (counter < n) {
visited[current_node] = true;
labels[current_node] = counter;
counter += 1;
for (auto neighbor : adjacency_list[current_node]) {
if (!visited[neighbor]) {
current_node = neighbor;
break;
}
}
}
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
if (t > s) return *max_element(c.begin(), c.end());
else return *min_element(c.begin(), c.end());
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
649 ms |
792 KB |
Output is correct |
2 |
Correct |
491 ms |
844 KB |
Output is correct |
3 |
Correct |
898 ms |
864 KB |
Output is correct |
4 |
Correct |
657 ms |
736 KB |
Output is correct |
5 |
Correct |
584 ms |
992 KB |
Output is correct |
6 |
Correct |
474 ms |
792 KB |
Output is correct |
7 |
Correct |
441 ms |
796 KB |
Output is correct |
8 |
Correct |
3 ms |
756 KB |
Output is correct |
9 |
Correct |
4 ms |
872 KB |
Output is correct |
10 |
Correct |
2 ms |
756 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
364 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
540 ms |
796 KB |
Output is correct |
2 |
Correct |
458 ms |
796 KB |
Output is correct |
3 |
Correct |
951 ms |
736 KB |
Output is correct |
4 |
Correct |
682 ms |
756 KB |
Output is correct |
5 |
Correct |
596 ms |
736 KB |
Output is correct |
6 |
Correct |
452 ms |
800 KB |
Output is correct |
7 |
Correct |
527 ms |
796 KB |
Output is correct |
8 |
Correct |
3 ms |
736 KB |
Output is correct |
9 |
Correct |
5 ms |
736 KB |
Output is correct |
10 |
Correct |
1 ms |
756 KB |
Output is correct |
11 |
Incorrect |
1 ms |
384 KB |
Invalid labels (duplicates values). scenario=1, label=0 |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1049 ms |
868 KB |
Output is correct |
2 |
Correct |
837 ms |
996 KB |
Output is correct |
3 |
Correct |
650 ms |
756 KB |
Output is correct |
4 |
Correct |
3 ms |
868 KB |
Output is correct |
5 |
Correct |
5 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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
644 ms |
756 KB |
Output is correct |
2 |
Correct |
538 ms |
936 KB |
Output is correct |
3 |
Correct |
934 ms |
736 KB |
Output is correct |
4 |
Correct |
680 ms |
736 KB |
Output is correct |
5 |
Correct |
638 ms |
992 KB |
Output is correct |
6 |
Correct |
521 ms |
788 KB |
Output is correct |
7 |
Correct |
500 ms |
908 KB |
Output is correct |
8 |
Correct |
4 ms |
756 KB |
Output is correct |
9 |
Correct |
4 ms |
672 KB |
Output is correct |
10 |
Correct |
1 ms |
860 KB |
Output is correct |
11 |
Incorrect |
5 ms |
364 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
12 |
Halted |
0 ms |
0 KB |
- |