#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;
++curt;
if(depth%2 == 0)
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:62:1: warning: control reaches end of non-void function [-Wreturn-type]
62 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
320 KB |
Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1990 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
308 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1022 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
810 ms |
640 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1059 ms |
404 KB |
Output is correct |
2 |
Correct |
730 ms |
620 KB |
Output is correct |
3 |
Incorrect |
664 ms |
512 KB |
Wrong query response. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
701 ms |
672 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |