#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N = 1e3 + 10;
int t;
vector<int> ans,adj[N];
void dfs(int v, int p, int c){
if(!c) ans[v]=++t;
for(int u : adj[v]) if(u!=p) dfs(u,v,1-c);
if(c) ans[v]=++t;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
ans.resize(n);
t=-1;
for(int i=0; i<n; i++) adj[i].clear();
for(int i=0; i<(int)v.size(); i++){
adj[v[i]].pb(u[i]);
adj[u[i]].pb(v[i]);
}
dfs(0,-1,0);
return ans;
}
int find_next_station(int s, int t, vector<int> c) {
int k;
if(s<c[0]){
k=c.back();
if(s) c.pop_back();
if(t<s || c.empty() || t>c.back()) return k;
return *lower_bound(c.begin(),c.end(),t);
}else{
k=c[0];
c.erase(c.begin());
if(c.empty() || t<c[0] || t>s) return k;
return *(upper_bound(c.begin(),c.end(),t)-1);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
486 ms |
520 KB |
Output is correct |
2 |
Correct |
446 ms |
520 KB |
Output is correct |
3 |
Correct |
1001 ms |
508 KB |
Output is correct |
4 |
Correct |
699 ms |
524 KB |
Output is correct |
5 |
Correct |
535 ms |
416 KB |
Output is correct |
6 |
Correct |
406 ms |
660 KB |
Output is correct |
7 |
Correct |
379 ms |
532 KB |
Output is correct |
8 |
Correct |
1 ms |
500 KB |
Output is correct |
9 |
Correct |
3 ms |
492 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
499 ms |
528 KB |
Output is correct |
2 |
Correct |
537 ms |
520 KB |
Output is correct |
3 |
Correct |
879 ms |
420 KB |
Output is correct |
4 |
Correct |
674 ms |
532 KB |
Output is correct |
5 |
Correct |
565 ms |
416 KB |
Output is correct |
6 |
Correct |
451 ms |
528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
536 ms |
680 KB |
Output is correct |
2 |
Correct |
454 ms |
668 KB |
Output is correct |
3 |
Correct |
922 ms |
548 KB |
Output is correct |
4 |
Correct |
584 ms |
416 KB |
Output is correct |
5 |
Correct |
598 ms |
420 KB |
Output is correct |
6 |
Correct |
425 ms |
544 KB |
Output is correct |
7 |
Correct |
433 ms |
520 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
5 ms |
488 KB |
Output is correct |
10 |
Correct |
0 ms |
500 KB |
Output is correct |
11 |
Correct |
613 ms |
524 KB |
Output is correct |
12 |
Correct |
459 ms |
628 KB |
Output is correct |
13 |
Correct |
545 ms |
620 KB |
Output is correct |
14 |
Correct |
397 ms |
528 KB |
Output is correct |
15 |
Correct |
46 ms |
420 KB |
Output is correct |
16 |
Correct |
65 ms |
544 KB |
Output is correct |
17 |
Correct |
76 ms |
528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
865 ms |
540 KB |
Output is correct |
2 |
Correct |
623 ms |
528 KB |
Output is correct |
3 |
Correct |
678 ms |
416 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
5 |
Correct |
3 ms |
492 KB |
Output is correct |
6 |
Correct |
2 ms |
540 KB |
Output is correct |
7 |
Correct |
618 ms |
532 KB |
Output is correct |
8 |
Correct |
967 ms |
508 KB |
Output is correct |
9 |
Correct |
712 ms |
528 KB |
Output is correct |
10 |
Correct |
702 ms |
528 KB |
Output is correct |
11 |
Correct |
6 ms |
492 KB |
Output is correct |
12 |
Correct |
6 ms |
492 KB |
Output is correct |
13 |
Correct |
6 ms |
492 KB |
Output is correct |
14 |
Correct |
5 ms |
500 KB |
Output is correct |
15 |
Correct |
2 ms |
488 KB |
Output is correct |
16 |
Correct |
404 ms |
528 KB |
Output is correct |
17 |
Correct |
577 ms |
524 KB |
Output is correct |
18 |
Correct |
554 ms |
528 KB |
Output is correct |
19 |
Correct |
521 ms |
524 KB |
Output is correct |
20 |
Correct |
468 ms |
508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
546 ms |
544 KB |
Output is correct |
2 |
Correct |
437 ms |
528 KB |
Output is correct |
3 |
Correct |
738 ms |
416 KB |
Output is correct |
4 |
Correct |
569 ms |
524 KB |
Output is correct |
5 |
Correct |
604 ms |
524 KB |
Output is correct |
6 |
Correct |
430 ms |
656 KB |
Output is correct |
7 |
Correct |
367 ms |
548 KB |
Output is correct |
8 |
Correct |
2 ms |
504 KB |
Output is correct |
9 |
Correct |
5 ms |
488 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
440 ms |
528 KB |
Output is correct |
12 |
Correct |
564 ms |
512 KB |
Output is correct |
13 |
Correct |
934 ms |
508 KB |
Output is correct |
14 |
Correct |
582 ms |
416 KB |
Output is correct |
15 |
Correct |
600 ms |
532 KB |
Output is correct |
16 |
Correct |
435 ms |
532 KB |
Output is correct |
17 |
Correct |
644 ms |
520 KB |
Output is correct |
18 |
Correct |
449 ms |
644 KB |
Output is correct |
19 |
Correct |
430 ms |
748 KB |
Output is correct |
20 |
Correct |
420 ms |
548 KB |
Output is correct |
21 |
Correct |
35 ms |
492 KB |
Output is correct |
22 |
Correct |
79 ms |
552 KB |
Output is correct |
23 |
Correct |
117 ms |
684 KB |
Output is correct |
24 |
Correct |
5 ms |
488 KB |
Output is correct |
25 |
Correct |
6 ms |
504 KB |
Output is correct |
26 |
Correct |
5 ms |
496 KB |
Output is correct |
27 |
Correct |
3 ms |
496 KB |
Output is correct |
28 |
Correct |
2 ms |
492 KB |
Output is correct |
29 |
Correct |
514 ms |
524 KB |
Output is correct |
30 |
Correct |
576 ms |
532 KB |
Output is correct |
31 |
Correct |
579 ms |
520 KB |
Output is correct |
32 |
Correct |
517 ms |
528 KB |
Output is correct |
33 |
Correct |
528 ms |
416 KB |
Output is correct |
34 |
Correct |
327 ms |
528 KB |
Output is correct |
35 |
Correct |
445 ms |
624 KB |
Output is correct |
36 |
Correct |
479 ms |
524 KB |
Output is correct |
37 |
Correct |
477 ms |
636 KB |
Output is correct |
38 |
Correct |
551 ms |
644 KB |
Output is correct |
39 |
Correct |
484 ms |
716 KB |
Output is correct |
40 |
Correct |
470 ms |
632 KB |
Output is correct |
41 |
Correct |
416 ms |
700 KB |
Output is correct |
42 |
Correct |
74 ms |
544 KB |
Output is correct |
43 |
Correct |
109 ms |
728 KB |
Output is correct |
44 |
Correct |
175 ms |
620 KB |
Output is correct |
45 |
Correct |
207 ms |
528 KB |
Output is correct |
46 |
Correct |
276 ms |
524 KB |
Output is correct |
47 |
Correct |
312 ms |
528 KB |
Output is correct |
48 |
Correct |
81 ms |
676 KB |
Output is correct |
49 |
Correct |
71 ms |
756 KB |
Output is correct |