#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> label(int n, int k, vector<int> U, vector<int> V){
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]);
}
vector<int> a(n);
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 |
404 ms |
612 KB |
Output is correct |
2 |
Correct |
403 ms |
528 KB |
Output is correct |
3 |
Correct |
761 ms |
400 KB |
Output is correct |
4 |
Correct |
651 ms |
400 KB |
Output is correct |
5 |
Correct |
587 ms |
400 KB |
Output is correct |
6 |
Correct |
324 ms |
520 KB |
Output is correct |
7 |
Correct |
443 ms |
616 KB |
Output is correct |
8 |
Correct |
2 ms |
476 KB |
Output is correct |
9 |
Correct |
4 ms |
468 KB |
Output is correct |
10 |
Correct |
0 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
441 ms |
548 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
520 ms |
528 KB |
Output is correct |
2 |
Correct |
439 ms |
528 KB |
Output is correct |
3 |
Correct |
749 ms |
400 KB |
Output is correct |
4 |
Correct |
490 ms |
488 KB |
Output is correct |
5 |
Correct |
563 ms |
492 KB |
Output is correct |
6 |
Correct |
469 ms |
660 KB |
Output is correct |
7 |
Correct |
358 ms |
532 KB |
Output is correct |
8 |
Correct |
2 ms |
476 KB |
Output is correct |
9 |
Correct |
4 ms |
480 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Incorrect |
539 ms |
612 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
934 ms |
488 KB |
Output is correct |
2 |
Correct |
664 ms |
400 KB |
Output is correct |
3 |
Correct |
471 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
476 KB |
Output is correct |
5 |
Correct |
3 ms |
476 KB |
Output is correct |
6 |
Correct |
1 ms |
476 KB |
Output is correct |
7 |
Incorrect |
575 ms |
496 KB |
Wrong query response. |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
428 ms |
528 KB |
Output is correct |
2 |
Correct |
428 ms |
620 KB |
Output is correct |
3 |
Correct |
829 ms |
484 KB |
Output is correct |
4 |
Correct |
563 ms |
476 KB |
Output is correct |
5 |
Correct |
554 ms |
404 KB |
Output is correct |
6 |
Correct |
458 ms |
528 KB |
Output is correct |
7 |
Correct |
376 ms |
616 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
3 ms |
476 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Incorrect |
365 ms |
528 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |