#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 3;
vector<int> adj[N];
int dfs(int u, int p, int idx, vector<int> &labels){
for(int to: adj[u]){
if(to == p) continue;
idx = dfs(to, u, idx, labels);
}
labels[u] = idx++;
return idx;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v){
for(int i = 0; i < n; ++i)
adj[i].clear();
for(int i = 0; i < n - 1; ++i){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
vector<int> labels(n);
dfs(0, -1, 0, labels);
return labels;
}
int find_next_station(int s, int t, vector<int> c){
for(int i = 0; i < c.size(); ++i)
if(c[i] >= t)
return c[i];
assert(false);
return -1;
}
/*
2
5 10
0 1
0 2
1 3
1 4
1
0 4 0
2 1
0 1
1
1 0 0
*/
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:34:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for(int i = 0; i < c.size(); ++i)
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
1144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
1076 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
1280 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1234 ms |
768 KB |
Output is correct |
2 |
Runtime error |
2 ms |
1140 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
1144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |