#include "stations.h"
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
vector<int> g[1009];
vector<int> ans;
int curt = 0;
void dfs(int v, int prt, int depth){
int tl = curt;
++curt;
for(auto u : g[v])
if(u != prt)
dfs(u, v, depth+1);
int tr = curt-1;
if(depth%2)
ans[v] = tl;
else
ans[v] = tr;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
ans = vector<int>(n);
for(int i = 0; i < n; ++i)
g[i].clear();
for(int i = 0; i < n-1; ++i){
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
curt = 0;
dfs(0, -1, 0);
return ans;
}
int find_next_station(int s, int t, std::vector<int> c) {
int smaller = 0;
for(auto u : c)
if(u < s)
smaller = 1;
if(smaller == 0){
sort(all(c));
for(auto u : c)
if(t <= u)
return u;
}
else{
sort(all(c), greater<int>());
for(auto u : c)
if(t >= u)
return u;
}
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:61:1: warning: control reaches end of non-void function [-Wreturn-type]
61 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
432 KB |
Invalid labels (duplicates values). scenario=0, label=9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
308 KB |
Invalid labels (duplicates values). scenario=0, label=995 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
428 KB |
Invalid labels (duplicates values). scenario=0, label=1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Invalid labels (duplicates values). scenario=0, label=1 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
328 KB |
Invalid labels (duplicates values). scenario=0, label=2 |
2 |
Halted |
0 ms |
0 KB |
- |