#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> g[1005];int l[1005];int z[1005];
int w(int n,int a){
int c=1;
for(auto i:g[n])if(i!=a)c+=w(i,n);
z[n]=c;return c;
}
void d(int n,int a,int e,bool p){
if(p)l[n]=a+z[n];
else l[n]=a-z[n];
int f=l[n];//cerr<<n<<' '<<f<<endl;
for(auto i:g[n])if(i!=e){d(i,f,n,!p);f=l[i];}
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
for(int i=0;i<n-1;i++){g[u[i]].push_back(v[i]);g[v[i]].push_back(u[i]);}
w(0,n);d(0,n,n,0);vector<int> r;
for(int i=0;i<n;i++){r.push_back(l[i]);g[i].clear();}
return r;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(s<c[0]){
if(t<s||t>=c.back())return c.back();
for(auto i:c)if(t<=i)return i;
}
else{
reverse(c.begin(),c.end());
if(t>s||t<=c.back())return c.back();
for(auto i:c)if(t>=i)return i;
}
exit(1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
531 ms |
516 KB |
Output is correct |
2 |
Correct |
555 ms |
520 KB |
Output is correct |
3 |
Correct |
985 ms |
516 KB |
Output is correct |
4 |
Correct |
783 ms |
516 KB |
Output is correct |
5 |
Correct |
671 ms |
400 KB |
Output is correct |
6 |
Correct |
534 ms |
528 KB |
Output is correct |
7 |
Correct |
434 ms |
520 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 |
476 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
542 ms |
516 KB |
Output is correct |
2 |
Correct |
623 ms |
528 KB |
Output is correct |
3 |
Correct |
1029 ms |
404 KB |
Output is correct |
4 |
Correct |
865 ms |
496 KB |
Output is correct |
5 |
Correct |
724 ms |
520 KB |
Output is correct |
6 |
Correct |
523 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
583 ms |
528 KB |
Output is correct |
2 |
Correct |
595 ms |
528 KB |
Output is correct |
3 |
Correct |
999 ms |
512 KB |
Output is correct |
4 |
Correct |
850 ms |
400 KB |
Output is correct |
5 |
Correct |
689 ms |
400 KB |
Output is correct |
6 |
Correct |
627 ms |
520 KB |
Output is correct |
7 |
Correct |
571 ms |
528 KB |
Output is correct |
8 |
Correct |
3 ms |
544 KB |
Output is correct |
9 |
Correct |
6 ms |
420 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
743 ms |
556 KB |
Output is correct |
12 |
Correct |
700 ms |
632 KB |
Output is correct |
13 |
Correct |
569 ms |
744 KB |
Output is correct |
14 |
Correct |
513 ms |
656 KB |
Output is correct |
15 |
Correct |
52 ms |
572 KB |
Output is correct |
16 |
Correct |
72 ms |
528 KB |
Output is correct |
17 |
Correct |
132 ms |
656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1061 ms |
400 KB |
Output is correct |
2 |
Correct |
769 ms |
400 KB |
Output is correct |
3 |
Correct |
751 ms |
516 KB |
Output is correct |
4 |
Correct |
4 ms |
468 KB |
Output is correct |
5 |
Correct |
6 ms |
472 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
727 ms |
400 KB |
Output is correct |
8 |
Correct |
966 ms |
516 KB |
Output is correct |
9 |
Correct |
792 ms |
476 KB |
Output is correct |
10 |
Correct |
629 ms |
512 KB |
Output is correct |
11 |
Correct |
5 ms |
468 KB |
Output is correct |
12 |
Correct |
6 ms |
500 KB |
Output is correct |
13 |
Correct |
5 ms |
476 KB |
Output is correct |
14 |
Correct |
6 ms |
476 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
584 ms |
400 KB |
Output is correct |
17 |
Correct |
528 ms |
400 KB |
Output is correct |
18 |
Correct |
551 ms |
400 KB |
Output is correct |
19 |
Correct |
539 ms |
512 KB |
Output is correct |
20 |
Correct |
574 ms |
520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
591 ms |
528 KB |
Output is correct |
2 |
Correct |
549 ms |
516 KB |
Output is correct |
3 |
Correct |
995 ms |
544 KB |
Output is correct |
4 |
Correct |
727 ms |
512 KB |
Output is correct |
5 |
Correct |
699 ms |
400 KB |
Output is correct |
6 |
Correct |
576 ms |
516 KB |
Output is correct |
7 |
Correct |
564 ms |
528 KB |
Output is correct |
8 |
Correct |
2 ms |
596 KB |
Output is correct |
9 |
Correct |
4 ms |
596 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Correct |
561 ms |
520 KB |
Output is correct |
12 |
Correct |
619 ms |
528 KB |
Output is correct |
13 |
Correct |
940 ms |
512 KB |
Output is correct |
14 |
Correct |
815 ms |
412 KB |
Output is correct |
15 |
Correct |
618 ms |
516 KB |
Output is correct |
16 |
Correct |
506 ms |
520 KB |
Output is correct |
17 |
Correct |
670 ms |
576 KB |
Output is correct |
18 |
Correct |
603 ms |
632 KB |
Output is correct |
19 |
Correct |
568 ms |
612 KB |
Output is correct |
20 |
Correct |
544 ms |
504 KB |
Output is correct |
21 |
Correct |
74 ms |
548 KB |
Output is correct |
22 |
Correct |
80 ms |
524 KB |
Output is correct |
23 |
Correct |
116 ms |
660 KB |
Output is correct |
24 |
Correct |
6 ms |
468 KB |
Output is correct |
25 |
Correct |
6 ms |
712 KB |
Output is correct |
26 |
Correct |
5 ms |
468 KB |
Output is correct |
27 |
Correct |
3 ms |
468 KB |
Output is correct |
28 |
Correct |
2 ms |
604 KB |
Output is correct |
29 |
Correct |
591 ms |
588 KB |
Output is correct |
30 |
Correct |
568 ms |
548 KB |
Output is correct |
31 |
Correct |
524 ms |
400 KB |
Output is correct |
32 |
Correct |
605 ms |
400 KB |
Output is correct |
33 |
Correct |
559 ms |
688 KB |
Output is correct |
34 |
Correct |
367 ms |
532 KB |
Output is correct |
35 |
Correct |
456 ms |
640 KB |
Output is correct |
36 |
Correct |
539 ms |
628 KB |
Output is correct |
37 |
Correct |
555 ms |
612 KB |
Output is correct |
38 |
Correct |
545 ms |
496 KB |
Output is correct |
39 |
Correct |
518 ms |
624 KB |
Output is correct |
40 |
Correct |
552 ms |
636 KB |
Output is correct |
41 |
Correct |
558 ms |
696 KB |
Output is correct |
42 |
Correct |
73 ms |
528 KB |
Output is correct |
43 |
Correct |
132 ms |
656 KB |
Output is correct |
44 |
Correct |
138 ms |
536 KB |
Output is correct |
45 |
Correct |
197 ms |
600 KB |
Output is correct |
46 |
Correct |
342 ms |
528 KB |
Output is correct |
47 |
Correct |
381 ms |
592 KB |
Output is correct |
48 |
Correct |
56 ms |
664 KB |
Output is correct |
49 |
Correct |
60 ms |
884 KB |
Output is correct |