#include "stations.h"
#ifndef EVAL
#include "stub.cpp"
#endif // EVAL
#include <bits/stdc++.h>
using namespace std;
#define lol long long
#define pii pair<int,int>
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define fr first
#define sc second
#define ret return
#define scanl(a) scanf("%lld",&a);
#define scanll(a,b) scanf("%lld %lld",&a, &b);
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define scan1(a) scanf("%d",&a);
#define scan2(a,b) scanf("%d %d",&a, &b);
#define scan3(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define pb push_back
#define sz(v) (int)v.size()
#define endi puts("");
#define eps 1e-12
const int N = 3e5+12,INF=1e9+7;
vector <int> g[N],asd;
int cnt;
void dfs(int x,int p,int s){
if (!s)
asd[x] = cnt++;
for (int to : g[x]){
if (to == p)continue;
dfs(to,x,s^1);
}
if (s)asd[x] = cnt++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for (int i = 0; i < n-1; i++) {
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
cnt=0;
asd.resize(n);
dfs(0,-1,0);
for (int i=0;i<n;++i){
g[i].clear();
}
return asd;
}
int find_next_station(int s, int t, vector<int> c) {
int mx = c[c.size()-1],i,n = c.size()-1;
if (mx < s){
for (i=n;i>=0;--i)
if (min(s,c[i]) <= t && t <= max(s,c[i]))ret c[i];
ret c[0];
}
else {
for (i=0;i<=n;++i)
if (min(s,c[i]) <= t && t <= max(s,c[i]))ret c[i];
ret c[n];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
541 ms |
14944 KB |
Output is correct |
2 |
Correct |
502 ms |
14944 KB |
Output is correct |
3 |
Correct |
869 ms |
14920 KB |
Output is correct |
4 |
Correct |
633 ms |
14816 KB |
Output is correct |
5 |
Correct |
566 ms |
14920 KB |
Output is correct |
6 |
Correct |
460 ms |
14944 KB |
Output is correct |
7 |
Correct |
486 ms |
14816 KB |
Output is correct |
8 |
Correct |
12 ms |
14928 KB |
Output is correct |
9 |
Correct |
13 ms |
14944 KB |
Output is correct |
10 |
Correct |
12 ms |
15048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
484 ms |
14852 KB |
Output is correct |
2 |
Correct |
603 ms |
14816 KB |
Output is correct |
3 |
Correct |
986 ms |
14920 KB |
Output is correct |
4 |
Correct |
749 ms |
14816 KB |
Output is correct |
5 |
Correct |
746 ms |
14816 KB |
Output is correct |
6 |
Correct |
509 ms |
14816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
645 ms |
15072 KB |
Output is correct |
2 |
Correct |
531 ms |
15036 KB |
Output is correct |
3 |
Correct |
968 ms |
14816 KB |
Output is correct |
4 |
Correct |
739 ms |
14920 KB |
Output is correct |
5 |
Correct |
716 ms |
14920 KB |
Output is correct |
6 |
Correct |
642 ms |
14944 KB |
Output is correct |
7 |
Correct |
615 ms |
14956 KB |
Output is correct |
8 |
Correct |
12 ms |
14928 KB |
Output is correct |
9 |
Correct |
13 ms |
14920 KB |
Output is correct |
10 |
Correct |
11 ms |
15068 KB |
Output is correct |
11 |
Correct |
632 ms |
15072 KB |
Output is correct |
12 |
Correct |
539 ms |
15188 KB |
Output is correct |
13 |
Correct |
520 ms |
15304 KB |
Output is correct |
14 |
Correct |
522 ms |
14816 KB |
Output is correct |
15 |
Correct |
68 ms |
14968 KB |
Output is correct |
16 |
Correct |
80 ms |
14816 KB |
Output is correct |
17 |
Correct |
122 ms |
14980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
973 ms |
14816 KB |
Output is correct |
2 |
Correct |
785 ms |
14816 KB |
Output is correct |
3 |
Correct |
762 ms |
14920 KB |
Output is correct |
4 |
Correct |
13 ms |
14920 KB |
Output is correct |
5 |
Correct |
14 ms |
14816 KB |
Output is correct |
6 |
Correct |
11 ms |
14920 KB |
Output is correct |
7 |
Correct |
753 ms |
14920 KB |
Output is correct |
8 |
Correct |
1066 ms |
14816 KB |
Output is correct |
9 |
Correct |
843 ms |
14828 KB |
Output is correct |
10 |
Correct |
781 ms |
14816 KB |
Output is correct |
11 |
Correct |
13 ms |
14816 KB |
Output is correct |
12 |
Correct |
13 ms |
14816 KB |
Output is correct |
13 |
Correct |
15 ms |
14816 KB |
Output is correct |
14 |
Correct |
15 ms |
14816 KB |
Output is correct |
15 |
Correct |
12 ms |
14920 KB |
Output is correct |
16 |
Correct |
588 ms |
14816 KB |
Output is correct |
17 |
Correct |
538 ms |
14920 KB |
Output is correct |
18 |
Correct |
570 ms |
14816 KB |
Output is correct |
19 |
Correct |
508 ms |
15048 KB |
Output is correct |
20 |
Correct |
540 ms |
14920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
698 ms |
14944 KB |
Output is correct |
2 |
Correct |
617 ms |
14944 KB |
Output is correct |
3 |
Correct |
1286 ms |
14816 KB |
Output is correct |
4 |
Correct |
780 ms |
14964 KB |
Output is correct |
5 |
Correct |
671 ms |
15064 KB |
Output is correct |
6 |
Correct |
513 ms |
14944 KB |
Output is correct |
7 |
Correct |
475 ms |
14816 KB |
Output is correct |
8 |
Correct |
11 ms |
14920 KB |
Output is correct |
9 |
Correct |
13 ms |
14932 KB |
Output is correct |
10 |
Correct |
11 ms |
14976 KB |
Output is correct |
11 |
Correct |
464 ms |
15120 KB |
Output is correct |
12 |
Correct |
562 ms |
15032 KB |
Output is correct |
13 |
Correct |
974 ms |
15092 KB |
Output is correct |
14 |
Correct |
668 ms |
14816 KB |
Output is correct |
15 |
Correct |
579 ms |
15072 KB |
Output is correct |
16 |
Correct |
438 ms |
14996 KB |
Output is correct |
17 |
Correct |
619 ms |
14816 KB |
Output is correct |
18 |
Correct |
482 ms |
15072 KB |
Output is correct |
19 |
Correct |
472 ms |
15072 KB |
Output is correct |
20 |
Correct |
425 ms |
14964 KB |
Output is correct |
21 |
Correct |
64 ms |
14816 KB |
Output is correct |
22 |
Correct |
74 ms |
14884 KB |
Output is correct |
23 |
Correct |
112 ms |
14828 KB |
Output is correct |
24 |
Correct |
13 ms |
14816 KB |
Output is correct |
25 |
Correct |
16 ms |
14816 KB |
Output is correct |
26 |
Correct |
13 ms |
14816 KB |
Output is correct |
27 |
Correct |
12 ms |
14816 KB |
Output is correct |
28 |
Correct |
11 ms |
14920 KB |
Output is correct |
29 |
Correct |
542 ms |
14816 KB |
Output is correct |
30 |
Correct |
510 ms |
14816 KB |
Output is correct |
31 |
Correct |
511 ms |
14816 KB |
Output is correct |
32 |
Correct |
536 ms |
14816 KB |
Output is correct |
33 |
Correct |
518 ms |
14828 KB |
Output is correct |
34 |
Correct |
371 ms |
15060 KB |
Output is correct |
35 |
Correct |
485 ms |
15160 KB |
Output is correct |
36 |
Correct |
575 ms |
15172 KB |
Output is correct |
37 |
Correct |
597 ms |
14944 KB |
Output is correct |
38 |
Correct |
561 ms |
14944 KB |
Output is correct |
39 |
Correct |
515 ms |
15076 KB |
Output is correct |
40 |
Correct |
493 ms |
15192 KB |
Output is correct |
41 |
Correct |
552 ms |
15072 KB |
Output is correct |
42 |
Correct |
88 ms |
14868 KB |
Output is correct |
43 |
Correct |
113 ms |
14852 KB |
Output is correct |
44 |
Correct |
141 ms |
14836 KB |
Output is correct |
45 |
Correct |
176 ms |
14832 KB |
Output is correct |
46 |
Correct |
301 ms |
14860 KB |
Output is correct |
47 |
Correct |
432 ms |
14816 KB |
Output is correct |
48 |
Correct |
74 ms |
15456 KB |
Output is correct |
49 |
Correct |
88 ms |
15328 KB |
Output is correct |