#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,int(v.size())) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
const int N=1000;
int Time,st[N],ft[N],h[N];
vector<int> g[N];
void dfs(int u,int p){
if(h[u]==0){
st[u]=Time++;
}
for(auto v : g[u]){
if(v==p) continue ;
h[v]=h[u]^1;
dfs(v,u);
}
if(h[u]==1){
ft[u]=Time++;
}
}
vector<int> label(int n, int k,vector<int> u,vector<int> v) {
vector<int> labels(n);
h[0]=Time=0;
f(i,0,n) g[i].clear();
f(i,0,n-1) g[u[i]].pb(v[i]),g[v[i]].pb(u[i]);
dfs(0,0);
f(i,0,n){
if(h[i]==0){
labels[i]=st[i];
}
else{
labels[i]=ft[i];
}
}
return labels;
}
int find_next_station(int s, int t,vector<int> c) {
for(auto v : c){
if(v==t){
return v;
}
}
c.pb(s);
sort(all(c));
if(c[0]==s){
f(i,0,int(c.size())-2){
if(c[i]<t && t<c[i+1]){
return c[i+1];
}
}
return c.back();
}
else{
f(i,1,int(c.size())-1){
if(c[i]<t && t<c[i+1]){
return c[i];
}
}
return c[0];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
539 ms |
648 KB |
Output is correct |
2 |
Correct |
494 ms |
688 KB |
Output is correct |
3 |
Correct |
925 ms |
520 KB |
Output is correct |
4 |
Correct |
559 ms |
520 KB |
Output is correct |
5 |
Correct |
535 ms |
548 KB |
Output is correct |
6 |
Correct |
440 ms |
524 KB |
Output is correct |
7 |
Correct |
425 ms |
588 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
5 ms |
632 KB |
Output is correct |
10 |
Correct |
1 ms |
620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
564 ms |
532 KB |
Output is correct |
2 |
Correct |
570 ms |
532 KB |
Output is correct |
3 |
Correct |
1004 ms |
532 KB |
Output is correct |
4 |
Correct |
736 ms |
548 KB |
Output is correct |
5 |
Correct |
692 ms |
504 KB |
Output is correct |
6 |
Correct |
529 ms |
544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
615 ms |
520 KB |
Output is correct |
2 |
Correct |
443 ms |
544 KB |
Output is correct |
3 |
Correct |
812 ms |
520 KB |
Output is correct |
4 |
Correct |
594 ms |
532 KB |
Output is correct |
5 |
Correct |
538 ms |
532 KB |
Output is correct |
6 |
Correct |
477 ms |
544 KB |
Output is correct |
7 |
Correct |
431 ms |
544 KB |
Output is correct |
8 |
Correct |
3 ms |
620 KB |
Output is correct |
9 |
Correct |
4 ms |
632 KB |
Output is correct |
10 |
Correct |
1 ms |
628 KB |
Output is correct |
11 |
Correct |
556 ms |
524 KB |
Output is correct |
12 |
Correct |
470 ms |
656 KB |
Output is correct |
13 |
Correct |
442 ms |
756 KB |
Output is correct |
14 |
Correct |
444 ms |
532 KB |
Output is correct |
15 |
Correct |
53 ms |
544 KB |
Output is correct |
16 |
Correct |
62 ms |
576 KB |
Output is correct |
17 |
Correct |
101 ms |
660 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
914 ms |
544 KB |
Output is correct |
2 |
Correct |
611 ms |
532 KB |
Output is correct |
3 |
Correct |
556 ms |
416 KB |
Output is correct |
4 |
Correct |
2 ms |
620 KB |
Output is correct |
5 |
Correct |
3 ms |
492 KB |
Output is correct |
6 |
Correct |
1 ms |
620 KB |
Output is correct |
7 |
Correct |
555 ms |
544 KB |
Output is correct |
8 |
Correct |
801 ms |
520 KB |
Output is correct |
9 |
Correct |
733 ms |
544 KB |
Output is correct |
10 |
Correct |
533 ms |
544 KB |
Output is correct |
11 |
Correct |
4 ms |
620 KB |
Output is correct |
12 |
Correct |
6 ms |
632 KB |
Output is correct |
13 |
Correct |
5 ms |
620 KB |
Output is correct |
14 |
Correct |
3 ms |
620 KB |
Output is correct |
15 |
Correct |
1 ms |
500 KB |
Output is correct |
16 |
Correct |
467 ms |
528 KB |
Output is correct |
17 |
Correct |
504 ms |
524 KB |
Output is correct |
18 |
Correct |
430 ms |
544 KB |
Output is correct |
19 |
Correct |
463 ms |
544 KB |
Output is correct |
20 |
Correct |
492 ms |
532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
546 ms |
544 KB |
Output is correct |
2 |
Correct |
480 ms |
548 KB |
Output is correct |
3 |
Correct |
901 ms |
520 KB |
Output is correct |
4 |
Correct |
652 ms |
416 KB |
Output is correct |
5 |
Correct |
579 ms |
544 KB |
Output is correct |
6 |
Correct |
416 ms |
716 KB |
Output is correct |
7 |
Correct |
378 ms |
532 KB |
Output is correct |
8 |
Correct |
2 ms |
620 KB |
Output is correct |
9 |
Correct |
3 ms |
628 KB |
Output is correct |
10 |
Correct |
1 ms |
620 KB |
Output is correct |
11 |
Correct |
499 ms |
548 KB |
Output is correct |
12 |
Correct |
498 ms |
544 KB |
Output is correct |
13 |
Correct |
915 ms |
420 KB |
Output is correct |
14 |
Correct |
659 ms |
416 KB |
Output is correct |
15 |
Correct |
537 ms |
524 KB |
Output is correct |
16 |
Correct |
374 ms |
544 KB |
Output is correct |
17 |
Correct |
542 ms |
548 KB |
Output is correct |
18 |
Correct |
496 ms |
640 KB |
Output is correct |
19 |
Correct |
459 ms |
648 KB |
Output is correct |
20 |
Correct |
403 ms |
540 KB |
Output is correct |
21 |
Correct |
64 ms |
572 KB |
Output is correct |
22 |
Correct |
72 ms |
572 KB |
Output is correct |
23 |
Correct |
124 ms |
668 KB |
Output is correct |
24 |
Correct |
5 ms |
620 KB |
Output is correct |
25 |
Correct |
5 ms |
492 KB |
Output is correct |
26 |
Correct |
3 ms |
620 KB |
Output is correct |
27 |
Correct |
4 ms |
628 KB |
Output is correct |
28 |
Correct |
1 ms |
500 KB |
Output is correct |
29 |
Correct |
511 ms |
524 KB |
Output is correct |
30 |
Correct |
543 ms |
548 KB |
Output is correct |
31 |
Correct |
486 ms |
524 KB |
Output is correct |
32 |
Correct |
491 ms |
532 KB |
Output is correct |
33 |
Correct |
543 ms |
420 KB |
Output is correct |
34 |
Correct |
357 ms |
544 KB |
Output is correct |
35 |
Correct |
452 ms |
768 KB |
Output is correct |
36 |
Correct |
451 ms |
768 KB |
Output is correct |
37 |
Correct |
489 ms |
648 KB |
Output is correct |
38 |
Correct |
467 ms |
672 KB |
Output is correct |
39 |
Correct |
414 ms |
660 KB |
Output is correct |
40 |
Correct |
426 ms |
788 KB |
Output is correct |
41 |
Correct |
386 ms |
636 KB |
Output is correct |
42 |
Correct |
55 ms |
572 KB |
Output is correct |
43 |
Correct |
83 ms |
668 KB |
Output is correct |
44 |
Correct |
111 ms |
544 KB |
Output is correct |
45 |
Correct |
150 ms |
528 KB |
Output is correct |
46 |
Correct |
319 ms |
524 KB |
Output is correct |
47 |
Correct |
337 ms |
548 KB |
Output is correct |
48 |
Correct |
60 ms |
700 KB |
Output is correct |
49 |
Correct |
53 ms |
780 KB |
Output is correct |