#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int Mx = 1010;
int timer = 0;
void dfs(int node,int par,vector<int> &labels,vector<vector<int>> &tr,bool parity){
if(parity)labels[node] = timer++;
for(auto i:tr[node]){
if(i != par){
dfs(i,node,labels,tr,!parity);
}
}
if(!parity)labels[node] = timer++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<int> labels(n);
vector<vector<int>> tr(n+1,vector<int>(0));
for (int i = 0; i < n-1; i++) {
tr[u[i]].push_back(v[i]);
tr[v[i]].push_back(u[i]);
}
dfs(0,-1,labels,tr,1);
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
if ((int)c.size() == 1) return c.back();
if (c.front() > s){
// s is tin
int l = s, r = c[(int)c.size() - 2];
if (l > t || r < t) return c.back(); // t out go to parent
int pos = lower_bound(c.begin(), c.end(), t) - c.begin(); // go to subtree where t
return c[pos];
} else {
// s is tout
int l = c[1], r = s;
if (l > t || r < t) return c.front(); // t out go to parent
int pos = upper_bound(c.begin(), c.end(), t) - c.begin() - 1; // go to subtree where t
return c[pos];
}
return c[0];
}
// c sorted
// small c deeper in the tree
// big c high in tree
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
456 KB |
Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1008 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
324 KB |
Invalid labels (values out of range). scenario=1, k=1000, vertex=1, label=1507 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
673 ms |
664 KB |
Output is correct |
2 |
Correct |
525 ms |
608 KB |
Output is correct |
3 |
Correct |
1079 ms |
400 KB |
Output is correct |
4 |
Correct |
684 ms |
400 KB |
Output is correct |
5 |
Correct |
724 ms |
400 KB |
Output is correct |
6 |
Correct |
534 ms |
620 KB |
Output is correct |
7 |
Correct |
501 ms |
616 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
5 ms |
444 KB |
Output is correct |
10 |
Correct |
2 ms |
472 KB |
Output is correct |
11 |
Correct |
696 ms |
400 KB |
Output is correct |
12 |
Correct |
591 ms |
608 KB |
Output is correct |
13 |
Correct |
545 ms |
812 KB |
Output is correct |
14 |
Correct |
591 ms |
520 KB |
Output is correct |
15 |
Correct |
56 ms |
468 KB |
Output is correct |
16 |
Correct |
83 ms |
528 KB |
Output is correct |
17 |
Correct |
146 ms |
528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1140 ms |
476 KB |
Output is correct |
2 |
Correct |
724 ms |
400 KB |
Output is correct |
3 |
Correct |
695 ms |
656 KB |
Output is correct |
4 |
Correct |
4 ms |
480 KB |
Output is correct |
5 |
Correct |
5 ms |
476 KB |
Output is correct |
6 |
Correct |
2 ms |
476 KB |
Output is correct |
7 |
Correct |
649 ms |
400 KB |
Output is correct |
8 |
Correct |
976 ms |
400 KB |
Output is correct |
9 |
Correct |
790 ms |
400 KB |
Output is correct |
10 |
Correct |
715 ms |
400 KB |
Output is correct |
11 |
Correct |
7 ms |
468 KB |
Output is correct |
12 |
Correct |
7 ms |
468 KB |
Output is correct |
13 |
Correct |
5 ms |
468 KB |
Output is correct |
14 |
Correct |
5 ms |
464 KB |
Output is correct |
15 |
Correct |
3 ms |
472 KB |
Output is correct |
16 |
Correct |
568 ms |
528 KB |
Output is correct |
17 |
Correct |
603 ms |
484 KB |
Output is correct |
18 |
Correct |
601 ms |
400 KB |
Output is correct |
19 |
Correct |
663 ms |
492 KB |
Output is correct |
20 |
Correct |
594 ms |
400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
582 ms |
656 KB |
Partially correct |
2 |
Partially correct |
535 ms |
520 KB |
Partially correct |
3 |
Correct |
944 ms |
400 KB |
Output is correct |
4 |
Correct |
717 ms |
400 KB |
Output is correct |
5 |
Correct |
623 ms |
400 KB |
Output is correct |
6 |
Partially correct |
495 ms |
740 KB |
Partially correct |
7 |
Correct |
493 ms |
488 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
5 ms |
456 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Partially correct |
513 ms |
488 KB |
Partially correct |
12 |
Partially correct |
597 ms |
528 KB |
Partially correct |
13 |
Correct |
980 ms |
400 KB |
Output is correct |
14 |
Correct |
795 ms |
548 KB |
Output is correct |
15 |
Correct |
759 ms |
488 KB |
Output is correct |
16 |
Correct |
620 ms |
528 KB |
Output is correct |
17 |
Correct |
649 ms |
400 KB |
Output is correct |
18 |
Partially correct |
514 ms |
768 KB |
Partially correct |
19 |
Partially correct |
530 ms |
740 KB |
Partially correct |
20 |
Correct |
490 ms |
528 KB |
Output is correct |
21 |
Correct |
60 ms |
428 KB |
Output is correct |
22 |
Partially correct |
90 ms |
528 KB |
Partially correct |
23 |
Partially correct |
141 ms |
528 KB |
Partially correct |
24 |
Correct |
6 ms |
476 KB |
Output is correct |
25 |
Correct |
8 ms |
468 KB |
Output is correct |
26 |
Correct |
6 ms |
476 KB |
Output is correct |
27 |
Correct |
5 ms |
480 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
576 ms |
400 KB |
Output is correct |
30 |
Correct |
512 ms |
400 KB |
Output is correct |
31 |
Correct |
502 ms |
488 KB |
Output is correct |
32 |
Correct |
570 ms |
616 KB |
Output is correct |
33 |
Correct |
595 ms |
484 KB |
Output is correct |
34 |
Partially correct |
356 ms |
640 KB |
Partially correct |
35 |
Partially correct |
553 ms |
680 KB |
Partially correct |
36 |
Partially correct |
594 ms |
528 KB |
Partially correct |
37 |
Partially correct |
491 ms |
488 KB |
Partially correct |
38 |
Partially correct |
579 ms |
732 KB |
Partially correct |
39 |
Partially correct |
567 ms |
732 KB |
Partially correct |
40 |
Partially correct |
556 ms |
840 KB |
Partially correct |
41 |
Partially correct |
537 ms |
728 KB |
Partially correct |
42 |
Partially correct |
66 ms |
528 KB |
Partially correct |
43 |
Partially correct |
142 ms |
576 KB |
Partially correct |
44 |
Partially correct |
156 ms |
656 KB |
Partially correct |
45 |
Partially correct |
149 ms |
480 KB |
Partially correct |
46 |
Partially correct |
290 ms |
484 KB |
Partially correct |
47 |
Partially correct |
358 ms |
604 KB |
Partially correct |
48 |
Partially correct |
76 ms |
528 KB |
Partially correct |
49 |
Partially correct |
80 ms |
660 KB |
Partially correct |