#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define FOR(i, n) for (int i = 0; i < n; i++)
vector<int> in, out;
vector<vector<int>> adj;
int tim = 0;
void dfs(int a, int p){
in[a] = tim++;
for (auto b : adj[a]){
if(b != p) dfs(b, a);
}
out[a] = tim-1;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<int> labels(n);
adj.assign(n, {});
tim = 0;
in = out = vector<int>(n);
FOR(i, n-1){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0, 0);
FOR(i, n){
labels[i] = out[i] + 1000*in[i];
}
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
int ins = s/1000;
int outs = s%1000;
int it = t/1000;
if(ins <= it && outs >= it){
for (auto i : c) {
int ii = i/1000;
int oi = i%1000;
if(ii > ins && ii <= it && oi >= it) return i;
}
}
else{
for (auto i : c) {
if(i / 1000 < ins) return i;
}
}
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:58:1: warning: control reaches end of non-void function [-Wreturn-type]
58 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
580 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6009 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
580 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1511 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
369 ms |
952 KB |
Output is correct |
2 |
Correct |
295 ms |
1108 KB |
Output is correct |
3 |
Correct |
594 ms |
684 KB |
Output is correct |
4 |
Correct |
445 ms |
684 KB |
Output is correct |
5 |
Correct |
385 ms |
944 KB |
Output is correct |
6 |
Correct |
290 ms |
908 KB |
Output is correct |
7 |
Correct |
299 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
848 KB |
Output is correct |
9 |
Correct |
3 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
764 KB |
Output is correct |
11 |
Correct |
382 ms |
684 KB |
Output is correct |
12 |
Correct |
334 ms |
988 KB |
Output is correct |
13 |
Correct |
354 ms |
1248 KB |
Output is correct |
14 |
Correct |
282 ms |
684 KB |
Output is correct |
15 |
Correct |
33 ms |
684 KB |
Output is correct |
16 |
Correct |
36 ms |
1128 KB |
Output is correct |
17 |
Correct |
69 ms |
1388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
558 ms |
684 KB |
Output is correct |
2 |
Correct |
422 ms |
688 KB |
Output is correct |
3 |
Correct |
355 ms |
692 KB |
Output is correct |
4 |
Correct |
1 ms |
760 KB |
Output is correct |
5 |
Correct |
4 ms |
768 KB |
Output is correct |
6 |
Correct |
1 ms |
768 KB |
Output is correct |
7 |
Correct |
402 ms |
684 KB |
Output is correct |
8 |
Correct |
585 ms |
684 KB |
Output is correct |
9 |
Correct |
447 ms |
684 KB |
Output is correct |
10 |
Correct |
394 ms |
688 KB |
Output is correct |
11 |
Correct |
3 ms |
764 KB |
Output is correct |
12 |
Correct |
4 ms |
768 KB |
Output is correct |
13 |
Correct |
4 ms |
768 KB |
Output is correct |
14 |
Correct |
2 ms |
768 KB |
Output is correct |
15 |
Correct |
1 ms |
768 KB |
Output is correct |
16 |
Correct |
332 ms |
684 KB |
Output is correct |
17 |
Correct |
327 ms |
684 KB |
Output is correct |
18 |
Correct |
351 ms |
684 KB |
Output is correct |
19 |
Correct |
364 ms |
684 KB |
Output is correct |
20 |
Correct |
339 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
360 ms |
952 KB |
Partially correct |
2 |
Partially correct |
293 ms |
936 KB |
Partially correct |
3 |
Partially correct |
552 ms |
684 KB |
Partially correct |
4 |
Partially correct |
429 ms |
684 KB |
Partially correct |
5 |
Partially correct |
385 ms |
684 KB |
Partially correct |
6 |
Partially correct |
297 ms |
904 KB |
Partially correct |
7 |
Partially correct |
293 ms |
684 KB |
Partially correct |
8 |
Partially correct |
1 ms |
768 KB |
Partially correct |
9 |
Partially correct |
2 ms |
768 KB |
Partially correct |
10 |
Partially correct |
0 ms |
768 KB |
Partially correct |
11 |
Partially correct |
279 ms |
1084 KB |
Partially correct |
12 |
Partially correct |
341 ms |
832 KB |
Partially correct |
13 |
Partially correct |
517 ms |
776 KB |
Partially correct |
14 |
Partially correct |
400 ms |
768 KB |
Partially correct |
15 |
Partially correct |
440 ms |
684 KB |
Partially correct |
16 |
Partially correct |
311 ms |
684 KB |
Partially correct |
17 |
Partially correct |
392 ms |
684 KB |
Partially correct |
18 |
Partially correct |
288 ms |
1148 KB |
Partially correct |
19 |
Partially correct |
286 ms |
1248 KB |
Partially correct |
20 |
Partially correct |
293 ms |
684 KB |
Partially correct |
21 |
Partially correct |
38 ms |
768 KB |
Partially correct |
22 |
Partially correct |
41 ms |
908 KB |
Partially correct |
23 |
Partially correct |
67 ms |
876 KB |
Partially correct |
24 |
Partially correct |
2 ms |
768 KB |
Partially correct |
25 |
Partially correct |
2 ms |
768 KB |
Partially correct |
26 |
Partially correct |
2 ms |
768 KB |
Partially correct |
27 |
Partially correct |
2 ms |
768 KB |
Partially correct |
28 |
Partially correct |
2 ms |
768 KB |
Partially correct |
29 |
Partially correct |
323 ms |
684 KB |
Partially correct |
30 |
Partially correct |
355 ms |
944 KB |
Partially correct |
31 |
Partially correct |
328 ms |
684 KB |
Partially correct |
32 |
Partially correct |
322 ms |
684 KB |
Partially correct |
33 |
Partially correct |
371 ms |
684 KB |
Partially correct |
34 |
Partially correct |
195 ms |
1040 KB |
Partially correct |
35 |
Partially correct |
278 ms |
1176 KB |
Partially correct |
36 |
Partially correct |
287 ms |
1092 KB |
Partially correct |
37 |
Partially correct |
295 ms |
1168 KB |
Partially correct |
38 |
Partially correct |
314 ms |
1000 KB |
Partially correct |
39 |
Partially correct |
310 ms |
1180 KB |
Partially correct |
40 |
Partially correct |
295 ms |
1016 KB |
Partially correct |
41 |
Partially correct |
326 ms |
1404 KB |
Partially correct |
42 |
Partially correct |
39 ms |
888 KB |
Partially correct |
43 |
Partially correct |
64 ms |
884 KB |
Partially correct |
44 |
Partially correct |
89 ms |
880 KB |
Partially correct |
45 |
Partially correct |
108 ms |
888 KB |
Partially correct |
46 |
Partially correct |
219 ms |
884 KB |
Partially correct |
47 |
Partially correct |
210 ms |
884 KB |
Partially correct |
48 |
Partially correct |
37 ms |
1228 KB |
Partially correct |
49 |
Partially correct |
34 ms |
1468 KB |
Partially correct |