//Fgrader.cpp
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
using ll = long long;
using ld = long double;
#define all(x) begin(x), end(x)
#define sz(x) ((int) (x).size())
const int N = 1010;
vector<int> g[N];
vector<int> ans;
int timer = 0;
void dfs(int u = 0, int p = -1, int depth = 1) {
if (depth) {
ans[u] = timer++;
}
for (int v : g[u]) {
if (v != p) {
dfs(v, u, depth ^ 1);
}
}
if (!depth) {
ans[u] = timer++;
}
}
vector<int> label(int n, int, vector<int> u, vector<int> v) {
for (int i = 0; i < n; ++i) {
g[i].clear();
}
timer = 0;
for (int i = 0; i < n - 1; ++i) {
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
ans.resize(n);
dfs();
return ans;
}
int find_next_station(int s, int t, vector<int> c) {
if (sz(c) == 1) {
return c[0];
}
if (!s) {
return *lower_bound(all(c), t);
}
if (s < c[0]) {
if (t < s || t > c[sz(c) - 2]) {
return c.back();
} else {
return *lower_bound(all(c), t);
}
} else {
if (t < c[1] || t > s) {
return c[0];
} else {
return *--upper_bound(all(c), t);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
579 ms |
640 KB |
Output is correct |
2 |
Correct |
482 ms |
548 KB |
Output is correct |
3 |
Correct |
843 ms |
416 KB |
Output is correct |
4 |
Correct |
660 ms |
524 KB |
Output is correct |
5 |
Correct |
537 ms |
532 KB |
Output is correct |
6 |
Correct |
387 ms |
524 KB |
Output is correct |
7 |
Correct |
481 ms |
536 KB |
Output is correct |
8 |
Correct |
3 ms |
492 KB |
Output is correct |
9 |
Correct |
3 ms |
500 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
501 ms |
588 KB |
Output is correct |
2 |
Correct |
535 ms |
524 KB |
Output is correct |
3 |
Correct |
975 ms |
484 KB |
Output is correct |
4 |
Correct |
725 ms |
416 KB |
Output is correct |
5 |
Correct |
628 ms |
528 KB |
Output is correct |
6 |
Correct |
511 ms |
536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
502 ms |
676 KB |
Output is correct |
2 |
Correct |
453 ms |
644 KB |
Output is correct |
3 |
Correct |
950 ms |
416 KB |
Output is correct |
4 |
Correct |
694 ms |
416 KB |
Output is correct |
5 |
Correct |
518 ms |
524 KB |
Output is correct |
6 |
Correct |
445 ms |
544 KB |
Output is correct |
7 |
Correct |
435 ms |
548 KB |
Output is correct |
8 |
Correct |
3 ms |
492 KB |
Output is correct |
9 |
Correct |
4 ms |
440 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
615 ms |
536 KB |
Output is correct |
12 |
Correct |
432 ms |
772 KB |
Output is correct |
13 |
Correct |
549 ms |
640 KB |
Output is correct |
14 |
Correct |
491 ms |
664 KB |
Output is correct |
15 |
Correct |
42 ms |
444 KB |
Output is correct |
16 |
Correct |
60 ms |
548 KB |
Output is correct |
17 |
Correct |
104 ms |
672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
698 ms |
416 KB |
Output is correct |
2 |
Correct |
718 ms |
532 KB |
Output is correct |
3 |
Correct |
594 ms |
416 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
4 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
624 ms |
416 KB |
Output is correct |
8 |
Correct |
944 ms |
416 KB |
Output is correct |
9 |
Correct |
650 ms |
524 KB |
Output is correct |
10 |
Correct |
538 ms |
416 KB |
Output is correct |
11 |
Correct |
4 ms |
492 KB |
Output is correct |
12 |
Correct |
6 ms |
492 KB |
Output is correct |
13 |
Correct |
4 ms |
556 KB |
Output is correct |
14 |
Correct |
4 ms |
492 KB |
Output is correct |
15 |
Correct |
1 ms |
492 KB |
Output is correct |
16 |
Correct |
397 ms |
524 KB |
Output is correct |
17 |
Correct |
461 ms |
528 KB |
Output is correct |
18 |
Correct |
389 ms |
420 KB |
Output is correct |
19 |
Correct |
497 ms |
420 KB |
Output is correct |
20 |
Correct |
358 ms |
528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
491 ms |
660 KB |
Output is correct |
2 |
Correct |
452 ms |
656 KB |
Output is correct |
3 |
Correct |
848 ms |
416 KB |
Output is correct |
4 |
Correct |
644 ms |
420 KB |
Output is correct |
5 |
Correct |
618 ms |
416 KB |
Output is correct |
6 |
Correct |
404 ms |
544 KB |
Output is correct |
7 |
Correct |
347 ms |
528 KB |
Output is correct |
8 |
Correct |
1 ms |
500 KB |
Output is correct |
9 |
Correct |
4 ms |
492 KB |
Output is correct |
10 |
Correct |
0 ms |
492 KB |
Output is correct |
11 |
Correct |
413 ms |
536 KB |
Output is correct |
12 |
Correct |
444 ms |
524 KB |
Output is correct |
13 |
Correct |
718 ms |
532 KB |
Output is correct |
14 |
Correct |
629 ms |
532 KB |
Output is correct |
15 |
Correct |
672 ms |
524 KB |
Output is correct |
16 |
Correct |
496 ms |
548 KB |
Output is correct |
17 |
Correct |
638 ms |
536 KB |
Output is correct |
18 |
Correct |
624 ms |
632 KB |
Output is correct |
19 |
Correct |
411 ms |
752 KB |
Output is correct |
20 |
Correct |
304 ms |
544 KB |
Output is correct |
21 |
Correct |
44 ms |
544 KB |
Output is correct |
22 |
Correct |
81 ms |
524 KB |
Output is correct |
23 |
Correct |
104 ms |
760 KB |
Output is correct |
24 |
Correct |
6 ms |
492 KB |
Output is correct |
25 |
Correct |
7 ms |
492 KB |
Output is correct |
26 |
Correct |
5 ms |
492 KB |
Output is correct |
27 |
Correct |
3 ms |
512 KB |
Output is correct |
28 |
Correct |
2 ms |
544 KB |
Output is correct |
29 |
Correct |
588 ms |
532 KB |
Output is correct |
30 |
Correct |
441 ms |
532 KB |
Output is correct |
31 |
Correct |
413 ms |
528 KB |
Output is correct |
32 |
Correct |
496 ms |
532 KB |
Output is correct |
33 |
Correct |
441 ms |
528 KB |
Output is correct |
34 |
Correct |
321 ms |
660 KB |
Output is correct |
35 |
Correct |
490 ms |
756 KB |
Output is correct |
36 |
Correct |
458 ms |
756 KB |
Output is correct |
37 |
Correct |
404 ms |
772 KB |
Output is correct |
38 |
Correct |
529 ms |
632 KB |
Output is correct |
39 |
Correct |
430 ms |
636 KB |
Output is correct |
40 |
Correct |
414 ms |
752 KB |
Output is correct |
41 |
Correct |
445 ms |
656 KB |
Output is correct |
42 |
Correct |
60 ms |
548 KB |
Output is correct |
43 |
Correct |
75 ms |
544 KB |
Output is correct |
44 |
Correct |
123 ms |
528 KB |
Output is correct |
45 |
Correct |
144 ms |
588 KB |
Output is correct |
46 |
Correct |
289 ms |
596 KB |
Output is correct |
47 |
Correct |
330 ms |
528 KB |
Output is correct |
48 |
Correct |
43 ms |
728 KB |
Output is correct |
49 |
Correct |
39 ms |
756 KB |
Output is correct |