#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define pb push_back
#define ln '\n'
//#define int long long
template <class _T>
bool chmin(_T &x, const _T &y){
bool flag = false;
if ( x > y ){
x = y; flag |= true;
}
return flag;
}
template <class _T>
bool chmax(_T &x, const _T &y){
bool flag = false;
if ( x < y ){
x = y; flag |= true;
}
return flag;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector <int> g[n], d(n, -1), tin(n), tout(n);
for ( int i = 0; i + 1 < n; i++ ){
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
vector <int> ans(n);
int timer = 1;
d[0] = 0;
function <void(int)> dfs = [&](int x){
tin[x] = timer++;
for ( auto to: g[x] ){
if ( d[to] == -1 ){
d[to] = d[x] + 1;
dfs(to);
}
}
tout[x] = timer++;
if ( !(d[x] & 1) ){
ans[x] = tin[x];
} else ans[x] = tout[x];
}; dfs(0);
vector <int> pos(n);
iota(all(pos), 0);
sort(all(pos), [&](int &x, int &y){
return ans[x] < ans[y];
});
vector <int> f(n);
for ( int i = 0; i < n; i++ ){
f[pos[i]] = i;
}
return f;
}
int find_next_station(int s, int t, vector<int> c) {
int n = (int)c.size();
if ( c.back() < s ){
for ( int i = n - 1; i > 0; i-- ){
if ( c[i] <= t and s >= t ){
return c[i];
}
}
return c[0];
}
for ( int i = 0; i + 1 < n; i++ ){
if ( c[i] >= t and s <= t ){
return c[i];
}
}
return c.back();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
468 ms |
676 KB |
Output is correct |
2 |
Correct |
335 ms |
632 KB |
Output is correct |
3 |
Correct |
656 ms |
416 KB |
Output is correct |
4 |
Correct |
639 ms |
508 KB |
Output is correct |
5 |
Correct |
370 ms |
604 KB |
Output is correct |
6 |
Correct |
400 ms |
640 KB |
Output is correct |
7 |
Correct |
336 ms |
540 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
3 ms |
492 KB |
Output is correct |
10 |
Correct |
0 ms |
500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
382 ms |
508 KB |
Output is correct |
2 |
Correct |
377 ms |
496 KB |
Output is correct |
3 |
Correct |
559 ms |
484 KB |
Output is correct |
4 |
Correct |
494 ms |
484 KB |
Output is correct |
5 |
Correct |
513 ms |
620 KB |
Output is correct |
6 |
Correct |
387 ms |
496 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
359 ms |
636 KB |
Output is correct |
2 |
Correct |
354 ms |
620 KB |
Output is correct |
3 |
Correct |
695 ms |
416 KB |
Output is correct |
4 |
Correct |
591 ms |
420 KB |
Output is correct |
5 |
Correct |
452 ms |
416 KB |
Output is correct |
6 |
Correct |
360 ms |
636 KB |
Output is correct |
7 |
Correct |
269 ms |
632 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
492 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Correct |
445 ms |
420 KB |
Output is correct |
12 |
Correct |
355 ms |
708 KB |
Output is correct |
13 |
Correct |
359 ms |
748 KB |
Output is correct |
14 |
Correct |
345 ms |
500 KB |
Output is correct |
15 |
Correct |
29 ms |
456 KB |
Output is correct |
16 |
Correct |
47 ms |
584 KB |
Output is correct |
17 |
Correct |
78 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
527 ms |
508 KB |
Output is correct |
2 |
Correct |
505 ms |
508 KB |
Output is correct |
3 |
Correct |
485 ms |
492 KB |
Output is correct |
4 |
Correct |
2 ms |
488 KB |
Output is correct |
5 |
Correct |
4 ms |
492 KB |
Output is correct |
6 |
Correct |
0 ms |
492 KB |
Output is correct |
7 |
Correct |
572 ms |
504 KB |
Output is correct |
8 |
Correct |
685 ms |
508 KB |
Output is correct |
9 |
Correct |
518 ms |
416 KB |
Output is correct |
10 |
Correct |
388 ms |
516 KB |
Output is correct |
11 |
Correct |
3 ms |
500 KB |
Output is correct |
12 |
Correct |
3 ms |
500 KB |
Output is correct |
13 |
Correct |
4 ms |
492 KB |
Output is correct |
14 |
Correct |
2 ms |
540 KB |
Output is correct |
15 |
Correct |
2 ms |
492 KB |
Output is correct |
16 |
Correct |
344 ms |
508 KB |
Output is correct |
17 |
Correct |
320 ms |
416 KB |
Output is correct |
18 |
Correct |
413 ms |
420 KB |
Output is correct |
19 |
Correct |
368 ms |
504 KB |
Output is correct |
20 |
Correct |
390 ms |
420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
374 ms |
636 KB |
Output is correct |
2 |
Correct |
349 ms |
628 KB |
Output is correct |
3 |
Correct |
597 ms |
416 KB |
Output is correct |
4 |
Correct |
565 ms |
508 KB |
Output is correct |
5 |
Correct |
345 ms |
508 KB |
Output is correct |
6 |
Correct |
366 ms |
676 KB |
Output is correct |
7 |
Correct |
344 ms |
632 KB |
Output is correct |
8 |
Correct |
1 ms |
500 KB |
Output is correct |
9 |
Correct |
3 ms |
500 KB |
Output is correct |
10 |
Correct |
0 ms |
496 KB |
Output is correct |
11 |
Correct |
365 ms |
500 KB |
Output is correct |
12 |
Correct |
460 ms |
544 KB |
Output is correct |
13 |
Correct |
800 ms |
512 KB |
Output is correct |
14 |
Correct |
518 ms |
504 KB |
Output is correct |
15 |
Correct |
498 ms |
420 KB |
Output is correct |
16 |
Correct |
311 ms |
548 KB |
Output is correct |
17 |
Correct |
475 ms |
508 KB |
Output is correct |
18 |
Correct |
280 ms |
708 KB |
Output is correct |
19 |
Correct |
358 ms |
716 KB |
Output is correct |
20 |
Correct |
235 ms |
504 KB |
Output is correct |
21 |
Correct |
53 ms |
492 KB |
Output is correct |
22 |
Correct |
43 ms |
548 KB |
Output is correct |
23 |
Correct |
64 ms |
548 KB |
Output is correct |
24 |
Correct |
4 ms |
492 KB |
Output is correct |
25 |
Correct |
4 ms |
492 KB |
Output is correct |
26 |
Correct |
3 ms |
492 KB |
Output is correct |
27 |
Correct |
2 ms |
500 KB |
Output is correct |
28 |
Correct |
1 ms |
488 KB |
Output is correct |
29 |
Correct |
328 ms |
504 KB |
Output is correct |
30 |
Correct |
344 ms |
504 KB |
Output is correct |
31 |
Correct |
343 ms |
504 KB |
Output is correct |
32 |
Correct |
424 ms |
420 KB |
Output is correct |
33 |
Correct |
416 ms |
420 KB |
Output is correct |
34 |
Correct |
279 ms |
652 KB |
Output is correct |
35 |
Correct |
307 ms |
752 KB |
Output is correct |
36 |
Correct |
363 ms |
628 KB |
Output is correct |
37 |
Correct |
341 ms |
612 KB |
Output is correct |
38 |
Correct |
382 ms |
628 KB |
Output is correct |
39 |
Correct |
342 ms |
756 KB |
Output is correct |
40 |
Correct |
356 ms |
700 KB |
Output is correct |
41 |
Correct |
299 ms |
512 KB |
Output is correct |
42 |
Correct |
43 ms |
652 KB |
Output is correct |
43 |
Correct |
70 ms |
572 KB |
Output is correct |
44 |
Correct |
85 ms |
544 KB |
Output is correct |
45 |
Correct |
107 ms |
504 KB |
Output is correct |
46 |
Correct |
225 ms |
508 KB |
Output is correct |
47 |
Correct |
210 ms |
544 KB |
Output is correct |
48 |
Correct |
41 ms |
600 KB |
Output is correct |
49 |
Correct |
48 ms |
620 KB |
Output is correct |