#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> edges[1005];
int a[1005];
vector<bool> used;
int timer=0;
void dfs(int u, int d){
if(d==0)a[u] = timer,timer++;
used[u] = true;
for(auto v:edges[u]){
if(used[v])continue;
dfs(v,d^1);
}if(d==1)a[u] = timer,timer++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for(int i=0;i<n;i++)edges[i].clear();
for(int i=0;i<n-1;i++){
edges[u[i]].push_back(v[i]);
edges[v[i]].push_back(u[i]);
}
timer=0;
used.assign(n,0);
dfs(0,0);
vector<int> ans(n);
for(int i=0;i<n;i++)ans[i] = a[i];
return ans;
}
/*
1
5 10
0 1
1 2
2 3
3 4
3
1 3 121
1 4 121
0 1 122
*/
int find_next_station(int s, int t, vector<int> c) {
// cout << s << ": " << t << '\n';
if(c[c.size()-1] < s){
int ans = c[0];
for(auto x : c){
if(min(s, x) <= t && t <= max(s, x))ans = x;
}return ans;
}else {
for(auto x : c)if(x>=t)return x;
}
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:54:1: warning: control reaches end of non-void function [-Wreturn-type]
54 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
526 ms |
1104 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
462 ms |
864 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
551 ms |
1144 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
897 ms |
940 KB |
Output is correct |
2 |
Correct |
627 ms |
1108 KB |
Output is correct |
3 |
Incorrect |
676 ms |
944 KB |
Wrong query response. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
677 ms |
984 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |