#include "bits/extc++.h"
using namespace std;
template <typename T>
void dbgh(const T& t) {
cerr << t << endl;
}
template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
cerr << t << " | ";
dbgh(u...);
}
#ifdef DEBUG
#define dbg(...) \
cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \
dbgh(__VA_ARGS__);
#else
#define dbg(...)
#define cerr \
if (false) \
cerr
#endif
#define endl "\n"
#define long int64_t
#define sz(x) int((x).size())
const int maxn = 1005;
int t, ans[maxn];
vector<int> graph[maxn];
void dfs(int u, int p = -1, int d = 0) {
if (!(d & 1)) {
ans[u] = t++;
}
for (auto& v : graph[u]) {
if (v != p) {
dfs(v, u, d + 1);
}
}
if (d & 1) {
ans[u] = t++;
}
dbg(u, ans[u]);
}
vector<int> label(int n, int, vector<int> u, vector<int> v) {
for (int i = 0; i < n; i++) {
graph[i].clear();
}
for (int i = 0; i < n - 1; i++) {
graph[u[i]].push_back(v[i]);
graph[v[i]].push_back(u[i]);
}
t = 0;
dfs(0);
return vector<int>(ans, ans + n);
}
int find_next_station(int s, int t, vector<int> c) {
assert(s != t);
if (sz(c) == 1) {
return c[0];
}
if (!s) {
return *lower_bound(begin(c), end(c), t);
}
if (s < c[0]) {
// I am tin, others are tout
if (s <= t && t <= c[sz(c) - 2]) {
return *lower_bound(begin(c), end(c), t);
} else {
return c.back();
}
} else {
// I am tout, others are tin
if (c[1] <= t && t <= s) {
return *(--upper_bound(begin(c), end(c), t));
} else {
return c[0];
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
512 ms |
640 KB |
Output is correct |
2 |
Correct |
391 ms |
672 KB |
Output is correct |
3 |
Correct |
881 ms |
416 KB |
Output is correct |
4 |
Correct |
711 ms |
532 KB |
Output is correct |
5 |
Correct |
578 ms |
516 KB |
Output is correct |
6 |
Correct |
438 ms |
656 KB |
Output is correct |
7 |
Correct |
422 ms |
528 KB |
Output is correct |
8 |
Correct |
3 ms |
628 KB |
Output is correct |
9 |
Correct |
5 ms |
576 KB |
Output is correct |
10 |
Correct |
0 ms |
488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
636 ms |
516 KB |
Output is correct |
2 |
Correct |
487 ms |
536 KB |
Output is correct |
3 |
Correct |
1009 ms |
468 KB |
Output is correct |
4 |
Correct |
681 ms |
416 KB |
Output is correct |
5 |
Correct |
626 ms |
524 KB |
Output is correct |
6 |
Correct |
471 ms |
508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
467 ms |
664 KB |
Output is correct |
2 |
Correct |
439 ms |
652 KB |
Output is correct |
3 |
Correct |
911 ms |
416 KB |
Output is correct |
4 |
Correct |
726 ms |
612 KB |
Output is correct |
5 |
Correct |
621 ms |
520 KB |
Output is correct |
6 |
Correct |
493 ms |
544 KB |
Output is correct |
7 |
Correct |
447 ms |
524 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
3 ms |
492 KB |
Output is correct |
10 |
Correct |
0 ms |
488 KB |
Output is correct |
11 |
Correct |
591 ms |
528 KB |
Output is correct |
12 |
Correct |
403 ms |
788 KB |
Output is correct |
13 |
Correct |
467 ms |
620 KB |
Output is correct |
14 |
Correct |
428 ms |
528 KB |
Output is correct |
15 |
Correct |
55 ms |
596 KB |
Output is correct |
16 |
Correct |
53 ms |
560 KB |
Output is correct |
17 |
Correct |
99 ms |
676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
757 ms |
416 KB |
Output is correct |
2 |
Correct |
639 ms |
536 KB |
Output is correct |
3 |
Correct |
662 ms |
416 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
0 ms |
492 KB |
Output is correct |
7 |
Correct |
574 ms |
448 KB |
Output is correct |
8 |
Correct |
825 ms |
416 KB |
Output is correct |
9 |
Correct |
468 ms |
528 KB |
Output is correct |
10 |
Correct |
564 ms |
424 KB |
Output is correct |
11 |
Correct |
4 ms |
496 KB |
Output is correct |
12 |
Correct |
6 ms |
492 KB |
Output is correct |
13 |
Correct |
6 ms |
492 KB |
Output is correct |
14 |
Correct |
4 ms |
492 KB |
Output is correct |
15 |
Correct |
2 ms |
492 KB |
Output is correct |
16 |
Correct |
515 ms |
420 KB |
Output is correct |
17 |
Correct |
462 ms |
532 KB |
Output is correct |
18 |
Correct |
505 ms |
416 KB |
Output is correct |
19 |
Correct |
495 ms |
532 KB |
Output is correct |
20 |
Correct |
384 ms |
536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
484 ms |
544 KB |
Output is correct |
2 |
Correct |
391 ms |
544 KB |
Output is correct |
3 |
Correct |
921 ms |
532 KB |
Output is correct |
4 |
Correct |
623 ms |
660 KB |
Output is correct |
5 |
Correct |
552 ms |
528 KB |
Output is correct |
6 |
Correct |
398 ms |
612 KB |
Output is correct |
7 |
Correct |
407 ms |
520 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
4 ms |
500 KB |
Output is correct |
10 |
Correct |
1 ms |
496 KB |
Output is correct |
11 |
Correct |
387 ms |
596 KB |
Output is correct |
12 |
Correct |
517 ms |
552 KB |
Output is correct |
13 |
Correct |
781 ms |
420 KB |
Output is correct |
14 |
Correct |
658 ms |
524 KB |
Output is correct |
15 |
Correct |
595 ms |
532 KB |
Output is correct |
16 |
Correct |
486 ms |
548 KB |
Output is correct |
17 |
Correct |
615 ms |
528 KB |
Output is correct |
18 |
Correct |
464 ms |
636 KB |
Output is correct |
19 |
Correct |
449 ms |
548 KB |
Output is correct |
20 |
Correct |
406 ms |
544 KB |
Output is correct |
21 |
Correct |
56 ms |
544 KB |
Output is correct |
22 |
Correct |
76 ms |
572 KB |
Output is correct |
23 |
Correct |
88 ms |
572 KB |
Output is correct |
24 |
Correct |
5 ms |
500 KB |
Output is correct |
25 |
Correct |
5 ms |
500 KB |
Output is correct |
26 |
Correct |
4 ms |
488 KB |
Output is correct |
27 |
Correct |
5 ms |
492 KB |
Output is correct |
28 |
Correct |
1 ms |
500 KB |
Output is correct |
29 |
Correct |
492 ms |
656 KB |
Output is correct |
30 |
Correct |
460 ms |
528 KB |
Output is correct |
31 |
Correct |
508 ms |
420 KB |
Output is correct |
32 |
Correct |
471 ms |
528 KB |
Output is correct |
33 |
Correct |
504 ms |
532 KB |
Output is correct |
34 |
Correct |
357 ms |
712 KB |
Output is correct |
35 |
Correct |
429 ms |
800 KB |
Output is correct |
36 |
Correct |
433 ms |
516 KB |
Output is correct |
37 |
Correct |
457 ms |
668 KB |
Output is correct |
38 |
Correct |
486 ms |
668 KB |
Output is correct |
39 |
Correct |
439 ms |
776 KB |
Output is correct |
40 |
Correct |
457 ms |
660 KB |
Output is correct |
41 |
Correct |
434 ms |
660 KB |
Output is correct |
42 |
Correct |
71 ms |
604 KB |
Output is correct |
43 |
Correct |
83 ms |
536 KB |
Output is correct |
44 |
Correct |
142 ms |
612 KB |
Output is correct |
45 |
Correct |
166 ms |
668 KB |
Output is correct |
46 |
Correct |
314 ms |
544 KB |
Output is correct |
47 |
Correct |
303 ms |
524 KB |
Output is correct |
48 |
Correct |
67 ms |
676 KB |
Output is correct |
49 |
Correct |
57 ms |
724 KB |
Output is correct |