#include <bits/stdc++.h>
#define pii pair<int,int>
#define f first
#define s second
using namespace std;
int t;
vector<int> edges[1000];
vector<pii> temp;
void dfs(int c, int p, bool h)
{
++t;
if (!h)
temp.push_back({t,c});
for (int i : edges[c])
if (i!=p)
dfs(i,c,h^1);
++t;
if (h)
temp.push_back({t,c});
}
vector<int> label(int n, int k, vector<int> u, vector<int> v)
{
vector<int> labels(n);
for (int i=0;i<n;++i)
edges[i].clear();
for (int i=0;i<n-1;++i)
{
edges[u[i]].push_back(v[i]);
edges[v[i]].push_back(u[i]);
}
temp.clear();
t=-1;
dfs(0,-1,0);
sort(temp.begin(), temp.end());
for (int i=0;i<n;++i)
labels[temp[i].s]=i;
return labels;
}
int find_next_station(int a, int b, vector<int> c)
{
int x = c.size();
sort(c.begin(), c.end());
if (a==0)
{
if (1<=b&&b<=c[0])
return c[0];
for (int i=1;i<x;++i)
if (c[i-1]+1<=b&&b<=c[i])
return c[i];
}
if (a<c[0])
{
if (x>1)
{
if (a+1<=b&&b<=c[0])
return c[0];
for (int i=1;i<x-1;++i)
if (c[i-1]+1<=b&&b<=c[i])
return c[i];
}
return c.back();
}
if (x>1)
{
if (c[x-1]<=b&&b<=a-1)
return c[x-1];
for (int i=x-2;i>0;--i)
if (c[i]<=b&&b<=c[i+1]-1)
return c[i];
}
return c[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
547 ms |
1024 KB |
Output is correct |
2 |
Correct |
466 ms |
1024 KB |
Output is correct |
3 |
Correct |
849 ms |
768 KB |
Output is correct |
4 |
Correct |
665 ms |
768 KB |
Output is correct |
5 |
Correct |
614 ms |
872 KB |
Output is correct |
6 |
Correct |
556 ms |
1040 KB |
Output is correct |
7 |
Correct |
590 ms |
1024 KB |
Output is correct |
8 |
Correct |
3 ms |
768 KB |
Output is correct |
9 |
Correct |
3 ms |
768 KB |
Output is correct |
10 |
Correct |
2 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
464 ms |
768 KB |
Output is correct |
2 |
Correct |
549 ms |
768 KB |
Output is correct |
3 |
Correct |
970 ms |
1008 KB |
Output is correct |
4 |
Correct |
674 ms |
768 KB |
Output is correct |
5 |
Correct |
625 ms |
768 KB |
Output is correct |
6 |
Correct |
453 ms |
784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
636 ms |
1008 KB |
Output is correct |
2 |
Correct |
470 ms |
1064 KB |
Output is correct |
3 |
Correct |
913 ms |
768 KB |
Output is correct |
4 |
Correct |
740 ms |
1008 KB |
Output is correct |
5 |
Correct |
648 ms |
880 KB |
Output is correct |
6 |
Correct |
586 ms |
1024 KB |
Output is correct |
7 |
Correct |
483 ms |
1024 KB |
Output is correct |
8 |
Correct |
2 ms |
876 KB |
Output is correct |
9 |
Correct |
5 ms |
1004 KB |
Output is correct |
10 |
Correct |
1 ms |
768 KB |
Output is correct |
11 |
Correct |
675 ms |
768 KB |
Output is correct |
12 |
Correct |
541 ms |
1112 KB |
Output is correct |
13 |
Correct |
515 ms |
1024 KB |
Output is correct |
14 |
Correct |
601 ms |
768 KB |
Output is correct |
15 |
Correct |
49 ms |
880 KB |
Output is correct |
16 |
Correct |
89 ms |
1128 KB |
Output is correct |
17 |
Correct |
144 ms |
936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
885 ms |
892 KB |
Output is correct |
2 |
Correct |
669 ms |
768 KB |
Output is correct |
3 |
Correct |
587 ms |
876 KB |
Output is correct |
4 |
Correct |
3 ms |
768 KB |
Output is correct |
5 |
Correct |
5 ms |
876 KB |
Output is correct |
6 |
Correct |
2 ms |
880 KB |
Output is correct |
7 |
Correct |
705 ms |
996 KB |
Output is correct |
8 |
Correct |
911 ms |
876 KB |
Output is correct |
9 |
Correct |
728 ms |
1032 KB |
Output is correct |
10 |
Correct |
608 ms |
872 KB |
Output is correct |
11 |
Correct |
7 ms |
888 KB |
Output is correct |
12 |
Correct |
6 ms |
768 KB |
Output is correct |
13 |
Correct |
6 ms |
768 KB |
Output is correct |
14 |
Correct |
5 ms |
876 KB |
Output is correct |
15 |
Correct |
2 ms |
896 KB |
Output is correct |
16 |
Correct |
526 ms |
768 KB |
Output is correct |
17 |
Correct |
488 ms |
1008 KB |
Output is correct |
18 |
Correct |
520 ms |
768 KB |
Output is correct |
19 |
Correct |
568 ms |
876 KB |
Output is correct |
20 |
Correct |
507 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
610 ms |
1024 KB |
Output is correct |
2 |
Correct |
473 ms |
1128 KB |
Output is correct |
3 |
Correct |
882 ms |
896 KB |
Output is correct |
4 |
Correct |
786 ms |
768 KB |
Output is correct |
5 |
Correct |
686 ms |
880 KB |
Output is correct |
6 |
Correct |
468 ms |
1024 KB |
Output is correct |
7 |
Correct |
451 ms |
1024 KB |
Output is correct |
8 |
Correct |
3 ms |
880 KB |
Output is correct |
9 |
Correct |
5 ms |
768 KB |
Output is correct |
10 |
Correct |
1 ms |
768 KB |
Output is correct |
11 |
Correct |
449 ms |
768 KB |
Output is correct |
12 |
Correct |
544 ms |
812 KB |
Output is correct |
13 |
Correct |
1004 ms |
768 KB |
Output is correct |
14 |
Correct |
756 ms |
912 KB |
Output is correct |
15 |
Correct |
720 ms |
1008 KB |
Output is correct |
16 |
Correct |
506 ms |
768 KB |
Output is correct |
17 |
Correct |
675 ms |
1044 KB |
Output is correct |
18 |
Correct |
489 ms |
1024 KB |
Output is correct |
19 |
Correct |
472 ms |
1024 KB |
Output is correct |
20 |
Correct |
436 ms |
1008 KB |
Output is correct |
21 |
Correct |
64 ms |
768 KB |
Output is correct |
22 |
Correct |
79 ms |
840 KB |
Output is correct |
23 |
Correct |
109 ms |
800 KB |
Output is correct |
24 |
Correct |
6 ms |
768 KB |
Output is correct |
25 |
Correct |
5 ms |
888 KB |
Output is correct |
26 |
Correct |
5 ms |
768 KB |
Output is correct |
27 |
Correct |
4 ms |
768 KB |
Output is correct |
28 |
Correct |
2 ms |
884 KB |
Output is correct |
29 |
Correct |
514 ms |
880 KB |
Output is correct |
30 |
Correct |
513 ms |
1016 KB |
Output is correct |
31 |
Correct |
546 ms |
1008 KB |
Output is correct |
32 |
Correct |
512 ms |
884 KB |
Output is correct |
33 |
Correct |
515 ms |
876 KB |
Output is correct |
34 |
Correct |
370 ms |
1008 KB |
Output is correct |
35 |
Correct |
444 ms |
1024 KB |
Output is correct |
36 |
Correct |
588 ms |
1024 KB |
Output is correct |
37 |
Correct |
500 ms |
888 KB |
Output is correct |
38 |
Correct |
462 ms |
788 KB |
Output is correct |
39 |
Correct |
451 ms |
1024 KB |
Output is correct |
40 |
Correct |
502 ms |
1024 KB |
Output is correct |
41 |
Correct |
564 ms |
772 KB |
Output is correct |
42 |
Correct |
68 ms |
816 KB |
Output is correct |
43 |
Correct |
114 ms |
816 KB |
Output is correct |
44 |
Correct |
125 ms |
792 KB |
Output is correct |
45 |
Correct |
218 ms |
768 KB |
Output is correct |
46 |
Correct |
312 ms |
804 KB |
Output is correct |
47 |
Correct |
352 ms |
780 KB |
Output is correct |
48 |
Correct |
69 ms |
776 KB |
Output is correct |
49 |
Correct |
70 ms |
1024 KB |
Output is correct |