#include "stations.h"
#include <vector>
#include <iostream>
using namespace std;
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
vector <vector<int>> e;
vector<int> labels;
e.resize(n);
int cnt = 0;
auto dfs = [&](auto self,int node, int p) -> void{
labels[node] = cnt++;
for(auto i:e[node]){
if(i == p)continue;
self(self, i, node);
}
};
labels.resize(n);
for(int i = 0;i < n - 1;i++){
e[u[i]].push_back(v[i]);
e[v[i]].push_back(u[i]);
}
for(int i = 0;i < n;i++){
if(e[i].size() == 1){
dfs(dfs, 0, -1);
break;
}
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(s < t){
///s go up
int mx = -1;
for(auto i:c){
mx = max(mx,i);
}
return mx;
}else{
///s go down?
int mn = 1000000;
for(auto i:c){
mn = min(mn,i);
}
return mn;
}
}
/**
1
7 99
0 1
0 2
1 3
1 4
2 5
2 6
**/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
494 ms |
668 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
417 ms |
668 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
483 ms |
668 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
818 ms |
668 KB |
Output is correct |
2 |
Incorrect |
595 ms |
668 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
491 ms |
668 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |