#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> a(n);
vector<vector<int>> g(n);
for(int i = 0; i < n - 1; i++){
g[U[i]].push_back(V[i]);
g[V[i]].push_back(U[i]);
}
int x = 0;
function<void(int, int)> dfs = [&](int u, int anc){
a[u] = x++;
for(int v : g[u]){
if(v != anc){
dfs(v, u);
}
}
};
for(int i = 0; ; i++){
if((int)g[i].size() == 1){
dfs(i, i);
return a;
}
}
}
int find_next_station(int s, int t, vector<int> c){
if(s > t){
return *min_element(c.begin(), c.end());
} else{
return *max_element(c.begin(), c.end());
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
474 ms |
524 KB |
Output is correct |
2 |
Correct |
477 ms |
660 KB |
Output is correct |
3 |
Correct |
857 ms |
400 KB |
Output is correct |
4 |
Correct |
673 ms |
400 KB |
Output is correct |
5 |
Correct |
676 ms |
400 KB |
Output is correct |
6 |
Correct |
504 ms |
524 KB |
Output is correct |
7 |
Correct |
463 ms |
596 KB |
Output is correct |
8 |
Correct |
3 ms |
452 KB |
Output is correct |
9 |
Correct |
1 ms |
476 KB |
Output is correct |
10 |
Correct |
1 ms |
476 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
407 ms |
612 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
520 ms |
520 KB |
Output is correct |
2 |
Correct |
430 ms |
524 KB |
Output is correct |
3 |
Correct |
846 ms |
400 KB |
Output is correct |
4 |
Correct |
601 ms |
400 KB |
Output is correct |
5 |
Correct |
585 ms |
400 KB |
Output is correct |
6 |
Correct |
425 ms |
624 KB |
Output is correct |
7 |
Correct |
443 ms |
524 KB |
Output is correct |
8 |
Correct |
2 ms |
532 KB |
Output is correct |
9 |
Correct |
3 ms |
476 KB |
Output is correct |
10 |
Correct |
0 ms |
468 KB |
Output is correct |
11 |
Incorrect |
554 ms |
400 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
939 ms |
464 KB |
Output is correct |
2 |
Correct |
657 ms |
400 KB |
Output is correct |
3 |
Correct |
591 ms |
464 KB |
Output is correct |
4 |
Correct |
3 ms |
468 KB |
Output is correct |
5 |
Correct |
4 ms |
476 KB |
Output is correct |
6 |
Correct |
1 ms |
476 KB |
Output is correct |
7 |
Incorrect |
551 ms |
404 KB |
Wrong query response. |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
389 ms |
828 KB |
Output is correct |
2 |
Correct |
379 ms |
528 KB |
Output is correct |
3 |
Correct |
788 ms |
488 KB |
Output is correct |
4 |
Correct |
586 ms |
400 KB |
Output is correct |
5 |
Correct |
597 ms |
400 KB |
Output is correct |
6 |
Correct |
416 ms |
600 KB |
Output is correct |
7 |
Correct |
439 ms |
596 KB |
Output is correct |
8 |
Correct |
3 ms |
404 KB |
Output is correct |
9 |
Correct |
4 ms |
536 KB |
Output is correct |
10 |
Correct |
0 ms |
468 KB |
Output is correct |
11 |
Incorrect |
375 ms |
524 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |