#include "stations.h"
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define svec(x) sort(all(x))
#define press(x) x.erase(unique(all(x)), x.end());
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef pair<LL, LL> pll;
const int INF=1e9;
const LL LLINF=1e18;
int n, re;
vector<int> link[1010], lab, id;
void dfs(int num, int par, int d){
re++;
if(d%2)lab[num-1]=re;
for(auto i:link[num]){
if(i==par)continue;
dfs(i, num, (d+1)%2);
}
if(d%2==0)lab[num-1]=re;
re++;
}
vector<int> label(int _n, int k, vector<int> u, vector<int> v) {
lab.resize(n);
n=_n;
for(int i=0; i<n-1; i++){
link[u[i]+1].eb(v[i]+1);
link[v[i]+1].eb(u[i]+1);
}
dfs(1, 0, 1);
svec(id); press(id);
for(auto &i:lab)i=lower_bound(all(id), i)-id.begin();
return lab;
}
int find_next_station(int s, int t, vector<int> c){
if(s<c[0]){
for(int i=0; i<c.size(); i++){
if(t<=c[i])return c[i];
}
}
else{
for(int i=c.size()-1; i>=0; i--){
if(t>=c[i])return c[i];
}
}
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:48:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
48 | for(int i=0; i<c.size(); i++){
| ~^~~~~~~~~
stations.cpp:57:1: warning: control reaches end of non-void function [-Wreturn-type]
57 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
524 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
636 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
532 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |