#include <bits/stdc++.h>
using namespace std;
int cnt;
vector<int> ret, sub;
vector<vector<int>> adj;
void dfs(int v, int p, bool ismax) {
ret[v] = cnt;
sub[v] = 1;
cnt += (!ismax);
for (auto to : adj[v]) {
if (to == p) continue;
dfs(to, v, !ismax);
if (ismax) ret[v] += sub[to];
sub[v] += sub[to];
}
cnt += ismax;
return;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
adj.assign(n, vector<int>());
for (int i=0; i<n-1; i++) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
sub.assign(n, 0);
ret.assign(n, 0);
cnt = 0;
dfs(0, 0, 0);
return ret;
}
int find_next_station(int s, int t, vector<int> c) {
bool ismax = (s > c[0]);
if (ismax) {
if (t > s) return c[0];
for (int i=1; i<(int)c.size(); i++) {
if (t < c[i]) return c[i-1];
}
return c[c.size()-1];
}
else {
if (t < s) return c[c.size()-1];
for (int i=c.size()-2; i>=0; i--) {
if (t > c[i]) return c[i+1];
}
//cout << "test " << c[0] << endl;
return c[0];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
554 ms |
656 KB |
Output is correct |
2 |
Correct |
398 ms |
616 KB |
Output is correct |
3 |
Correct |
798 ms |
400 KB |
Output is correct |
4 |
Correct |
627 ms |
404 KB |
Output is correct |
5 |
Correct |
580 ms |
488 KB |
Output is correct |
6 |
Correct |
447 ms |
624 KB |
Output is correct |
7 |
Correct |
510 ms |
528 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
5 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
429 ms |
560 KB |
Output is correct |
2 |
Correct |
589 ms |
480 KB |
Output is correct |
3 |
Correct |
855 ms |
400 KB |
Output is correct |
4 |
Correct |
591 ms |
400 KB |
Output is correct |
5 |
Correct |
525 ms |
400 KB |
Output is correct |
6 |
Correct |
341 ms |
532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
466 ms |
616 KB |
Output is correct |
2 |
Correct |
421 ms |
604 KB |
Output is correct |
3 |
Correct |
913 ms |
488 KB |
Output is correct |
4 |
Correct |
492 ms |
492 KB |
Output is correct |
5 |
Correct |
467 ms |
400 KB |
Output is correct |
6 |
Correct |
350 ms |
528 KB |
Output is correct |
7 |
Correct |
483 ms |
532 KB |
Output is correct |
8 |
Correct |
1 ms |
476 KB |
Output is correct |
9 |
Correct |
4 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
481 ms |
488 KB |
Output is correct |
12 |
Correct |
438 ms |
612 KB |
Output is correct |
13 |
Correct |
492 ms |
852 KB |
Output is correct |
14 |
Correct |
442 ms |
484 KB |
Output is correct |
15 |
Correct |
50 ms |
420 KB |
Output is correct |
16 |
Correct |
59 ms |
668 KB |
Output is correct |
17 |
Correct |
115 ms |
520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1004 ms |
428 KB |
Output is correct |
2 |
Correct |
569 ms |
404 KB |
Output is correct |
3 |
Correct |
528 ms |
484 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
4 ms |
468 KB |
Output is correct |
6 |
Correct |
0 ms |
468 KB |
Output is correct |
7 |
Correct |
601 ms |
492 KB |
Output is correct |
8 |
Correct |
936 ms |
480 KB |
Output is correct |
9 |
Correct |
501 ms |
400 KB |
Output is correct |
10 |
Correct |
396 ms |
492 KB |
Output is correct |
11 |
Correct |
6 ms |
476 KB |
Output is correct |
12 |
Correct |
4 ms |
448 KB |
Output is correct |
13 |
Correct |
5 ms |
468 KB |
Output is correct |
14 |
Correct |
4 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
515 ms |
404 KB |
Output is correct |
17 |
Correct |
515 ms |
400 KB |
Output is correct |
18 |
Correct |
568 ms |
400 KB |
Output is correct |
19 |
Correct |
509 ms |
400 KB |
Output is correct |
20 |
Correct |
468 ms |
400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
490 ms |
656 KB |
Output is correct |
2 |
Correct |
444 ms |
652 KB |
Output is correct |
3 |
Correct |
857 ms |
484 KB |
Output is correct |
4 |
Correct |
596 ms |
532 KB |
Output is correct |
5 |
Correct |
444 ms |
488 KB |
Output is correct |
6 |
Correct |
435 ms |
604 KB |
Output is correct |
7 |
Correct |
450 ms |
528 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
4 ms |
468 KB |
Output is correct |
10 |
Correct |
0 ms |
468 KB |
Output is correct |
11 |
Correct |
495 ms |
600 KB |
Output is correct |
12 |
Correct |
659 ms |
464 KB |
Output is correct |
13 |
Correct |
852 ms |
400 KB |
Output is correct |
14 |
Correct |
818 ms |
536 KB |
Output is correct |
15 |
Correct |
479 ms |
532 KB |
Output is correct |
16 |
Correct |
514 ms |
480 KB |
Output is correct |
17 |
Correct |
582 ms |
464 KB |
Output is correct |
18 |
Correct |
391 ms |
692 KB |
Output is correct |
19 |
Correct |
462 ms |
676 KB |
Output is correct |
20 |
Correct |
454 ms |
472 KB |
Output is correct |
21 |
Correct |
60 ms |
404 KB |
Output is correct |
22 |
Correct |
59 ms |
532 KB |
Output is correct |
23 |
Correct |
99 ms |
528 KB |
Output is correct |
24 |
Correct |
5 ms |
468 KB |
Output is correct |
25 |
Correct |
4 ms |
472 KB |
Output is correct |
26 |
Correct |
4 ms |
468 KB |
Output is correct |
27 |
Correct |
4 ms |
532 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
456 ms |
404 KB |
Output is correct |
30 |
Correct |
423 ms |
472 KB |
Output is correct |
31 |
Correct |
499 ms |
488 KB |
Output is correct |
32 |
Correct |
446 ms |
400 KB |
Output is correct |
33 |
Correct |
484 ms |
480 KB |
Output is correct |
34 |
Correct |
286 ms |
604 KB |
Output is correct |
35 |
Correct |
438 ms |
612 KB |
Output is correct |
36 |
Correct |
374 ms |
680 KB |
Output is correct |
37 |
Correct |
384 ms |
604 KB |
Output is correct |
38 |
Correct |
414 ms |
604 KB |
Output is correct |
39 |
Correct |
449 ms |
928 KB |
Output is correct |
40 |
Correct |
439 ms |
684 KB |
Output is correct |
41 |
Correct |
433 ms |
608 KB |
Output is correct |
42 |
Correct |
62 ms |
548 KB |
Output is correct |
43 |
Correct |
98 ms |
476 KB |
Output is correct |
44 |
Correct |
138 ms |
588 KB |
Output is correct |
45 |
Correct |
186 ms |
528 KB |
Output is correct |
46 |
Correct |
293 ms |
484 KB |
Output is correct |
47 |
Correct |
305 ms |
468 KB |
Output is correct |
48 |
Correct |
73 ms |
740 KB |
Output is correct |
49 |
Correct |
41 ms |
776 KB |
Output is correct |