#include <bits/stdc++.h>
#include "stations.h"
#define y e[x][i]
using namespace std;
typedef vector<int> vec;
int sum;
vector<vec> e;
vec res;
void dfs(int x,int fa,bool d){
if(d) res[x]=sum++;
for(int i=0;i<e[x].size();i++)
if(y!=fa) dfs(y,x,d^1);
if(!d) res[x]=sum++;
}
vec label(int n,int k,vec u,vec v){
res.resize(n);e.resize(n,vec());
for(int i=0;i<n-1;i++) {e[u[i]].push_back(v[i]);e[v[i]].push_back(u[i]);}
sum=0;dfs(0,-1,1);return res;
}
int find_next_station(int s,int t,vec c){
if(c[0]>s){
if(t<s||c.back()<t) return c.back();
return *lower_bound(c.begin(),c.end(),t);
}
if(t<c[0]||s<t) return c[0];
return *(upper_bound(c.begin(),c.end(),t)-1);
}
Compilation message
stations.cpp: In function 'void dfs(int, int, bool)':
stations.cpp:11:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
11 | for(int i=0;i<e[x].size();i++)
| ~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3059 ms |
2376 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1481 ms |
2097156 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
993 ms |
756 KB |
Output is correct |
2 |
Runtime error |
1243 ms |
2097152 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2487 ms |
2097156 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |