#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
// #define int long long
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<vector<int>> g(n);
for(int i = 0; i < n - 1; i++) {
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
int t = 0;
vector<int> ret(n);
function<void(int, int, bool)> dfs = [&](int to, int fr, bool fl) {
if(fl) ret[to] = t++;
fl = !fl;
for(int x : g[to]) {
if(x == fr) continue;
dfs(x, to, fl);
}
if(fl) ret[to] = t++;
};
dfs(0, -1, false);
return ret;
}
int find_next_station(int s, int t, vector<int> c) {
if(c.back() > s) {
for(int i = 0; i + 1 < c.size(); i++) {
if(t >= s && t <= c[i]) return c[i];
}
return c.back();
} else {
for(int i = (int)c.size() - 1; i > 0; i--) {
if(t >= c[i] && t <= s) return c[i];
}
return c[0];
}
return 69;
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:44:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for(int i = 0; i + 1 < c.size(); i++) {
| ~~~~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
336 ms |
720 KB |
Output is correct |
2 |
Correct |
447 ms |
636 KB |
Output is correct |
3 |
Correct |
745 ms |
416 KB |
Output is correct |
4 |
Correct |
502 ms |
420 KB |
Output is correct |
5 |
Correct |
396 ms |
420 KB |
Output is correct |
6 |
Correct |
403 ms |
672 KB |
Output is correct |
7 |
Correct |
306 ms |
544 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
3 ms |
500 KB |
Output is correct |
10 |
Correct |
0 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
319 ms |
588 KB |
Output is correct |
2 |
Correct |
429 ms |
544 KB |
Output is correct |
3 |
Correct |
674 ms |
420 KB |
Output is correct |
4 |
Correct |
577 ms |
420 KB |
Output is correct |
5 |
Correct |
444 ms |
500 KB |
Output is correct |
6 |
Correct |
332 ms |
544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
499 ms |
640 KB |
Output is correct |
2 |
Correct |
392 ms |
640 KB |
Output is correct |
3 |
Correct |
616 ms |
420 KB |
Output is correct |
4 |
Correct |
460 ms |
504 KB |
Output is correct |
5 |
Correct |
407 ms |
500 KB |
Output is correct |
6 |
Correct |
353 ms |
676 KB |
Output is correct |
7 |
Correct |
355 ms |
632 KB |
Output is correct |
8 |
Correct |
0 ms |
492 KB |
Output is correct |
9 |
Correct |
3 ms |
492 KB |
Output is correct |
10 |
Correct |
0 ms |
524 KB |
Output is correct |
11 |
Correct |
468 ms |
500 KB |
Output is correct |
12 |
Correct |
404 ms |
712 KB |
Output is correct |
13 |
Correct |
406 ms |
796 KB |
Output is correct |
14 |
Correct |
278 ms |
500 KB |
Output is correct |
15 |
Correct |
39 ms |
492 KB |
Output is correct |
16 |
Correct |
58 ms |
584 KB |
Output is correct |
17 |
Correct |
88 ms |
544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
639 ms |
416 KB |
Output is correct |
2 |
Correct |
487 ms |
416 KB |
Output is correct |
3 |
Correct |
504 ms |
508 KB |
Output is correct |
4 |
Correct |
1 ms |
496 KB |
Output is correct |
5 |
Correct |
3 ms |
504 KB |
Output is correct |
6 |
Correct |
0 ms |
492 KB |
Output is correct |
7 |
Correct |
525 ms |
508 KB |
Output is correct |
8 |
Correct |
706 ms |
508 KB |
Output is correct |
9 |
Correct |
520 ms |
416 KB |
Output is correct |
10 |
Correct |
516 ms |
508 KB |
Output is correct |
11 |
Correct |
3 ms |
496 KB |
Output is correct |
12 |
Correct |
5 ms |
492 KB |
Output is correct |
13 |
Correct |
3 ms |
492 KB |
Output is correct |
14 |
Correct |
2 ms |
488 KB |
Output is correct |
15 |
Correct |
1 ms |
492 KB |
Output is correct |
16 |
Correct |
324 ms |
420 KB |
Output is correct |
17 |
Correct |
451 ms |
416 KB |
Output is correct |
18 |
Correct |
379 ms |
416 KB |
Output is correct |
19 |
Correct |
377 ms |
508 KB |
Output is correct |
20 |
Correct |
357 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
403 ms |
676 KB |
Output is correct |
2 |
Correct |
369 ms |
672 KB |
Output is correct |
3 |
Correct |
787 ms |
416 KB |
Output is correct |
4 |
Correct |
527 ms |
416 KB |
Output is correct |
5 |
Correct |
455 ms |
504 KB |
Output is correct |
6 |
Correct |
457 ms |
624 KB |
Output is correct |
7 |
Correct |
371 ms |
544 KB |
Output is correct |
8 |
Correct |
1 ms |
500 KB |
Output is correct |
9 |
Correct |
3 ms |
492 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
333 ms |
504 KB |
Output is correct |
12 |
Correct |
388 ms |
548 KB |
Output is correct |
13 |
Correct |
622 ms |
548 KB |
Output is correct |
14 |
Correct |
516 ms |
420 KB |
Output is correct |
15 |
Correct |
465 ms |
512 KB |
Output is correct |
16 |
Correct |
374 ms |
548 KB |
Output is correct |
17 |
Correct |
460 ms |
504 KB |
Output is correct |
18 |
Correct |
408 ms |
716 KB |
Output is correct |
19 |
Correct |
450 ms |
800 KB |
Output is correct |
20 |
Correct |
384 ms |
544 KB |
Output is correct |
21 |
Correct |
28 ms |
416 KB |
Output is correct |
22 |
Correct |
59 ms |
572 KB |
Output is correct |
23 |
Correct |
108 ms |
544 KB |
Output is correct |
24 |
Correct |
5 ms |
492 KB |
Output is correct |
25 |
Correct |
4 ms |
492 KB |
Output is correct |
26 |
Correct |
4 ms |
500 KB |
Output is correct |
27 |
Correct |
2 ms |
500 KB |
Output is correct |
28 |
Correct |
1 ms |
492 KB |
Output is correct |
29 |
Correct |
312 ms |
508 KB |
Output is correct |
30 |
Correct |
506 ms |
504 KB |
Output is correct |
31 |
Correct |
484 ms |
420 KB |
Output is correct |
32 |
Correct |
412 ms |
416 KB |
Output is correct |
33 |
Correct |
362 ms |
504 KB |
Output is correct |
34 |
Correct |
243 ms |
676 KB |
Output is correct |
35 |
Correct |
286 ms |
712 KB |
Output is correct |
36 |
Correct |
335 ms |
712 KB |
Output is correct |
37 |
Correct |
343 ms |
588 KB |
Output is correct |
38 |
Correct |
350 ms |
680 KB |
Output is correct |
39 |
Correct |
465 ms |
592 KB |
Output is correct |
40 |
Correct |
419 ms |
636 KB |
Output is correct |
41 |
Correct |
263 ms |
588 KB |
Output is correct |
42 |
Correct |
50 ms |
548 KB |
Output is correct |
43 |
Correct |
86 ms |
548 KB |
Output is correct |
44 |
Correct |
137 ms |
548 KB |
Output is correct |
45 |
Correct |
142 ms |
544 KB |
Output is correct |
46 |
Correct |
208 ms |
548 KB |
Output is correct |
47 |
Correct |
205 ms |
700 KB |
Output is correct |
48 |
Correct |
44 ms |
600 KB |
Output is correct |
49 |
Correct |
51 ms |
716 KB |
Output is correct |