#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXM = 1e3+10;
vector<vector<int> > graph;
int depth[MAXM];
int val[MAXM];
int seq = 0;
void dfs(int here,int p){
int there;
if(!(depth[here]&1)){
val[here] = seq;
seq++;
}
for(int i=0;i<(int)graph[here].size();i++){
there = graph[here][i];
if(there==p)continue;
depth[there] = depth[here]^1;
dfs(there,here);
}
if(depth[here]&1){
val[here] = seq;
seq++;
}
return;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
graph = vector<vector<int> > (n);
for(int i=0;i<n-1;i++){
graph[u[i]].push_back(v[i]);
graph[v[i]].push_back(u[i]);
}
seq = 0;
depth[0] = 0;
dfs(0,-1);
vector<int> labels(n);
for(int i=0;i<n;i++){
labels[i] = val[i];
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
int m = (int)c.size();
if(m==1)return c[0];
int idx = -1;
int pre = 0;
int nxt = 0;
if(s<c[0]){
pre = s;
for(int i=0;i<m-1;i++){
if(pre+1<=t&&t<=c[i]){
idx = i;
break;
}
pre = c[i];
}
if(idx==-1)idx = m-1;
}
else {
for(int i=1;i<m;i++){
if(i==m-1)nxt = s;
else nxt = c[i+1];
if(c[i]<=t&&t<=nxt-1){
idx = i;
break;
}
}
if(idx==-1)idx = 0;
}
assert(idx!=-1);
return c[idx];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
531 ms |
608 KB |
Output is correct |
2 |
Correct |
544 ms |
656 KB |
Output is correct |
3 |
Correct |
1079 ms |
528 KB |
Output is correct |
4 |
Correct |
858 ms |
400 KB |
Output is correct |
5 |
Correct |
711 ms |
472 KB |
Output is correct |
6 |
Correct |
602 ms |
616 KB |
Output is correct |
7 |
Correct |
633 ms |
480 KB |
Output is correct |
8 |
Correct |
3 ms |
464 KB |
Output is correct |
9 |
Correct |
3 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
625 ms |
532 KB |
Output is correct |
2 |
Correct |
556 ms |
484 KB |
Output is correct |
3 |
Correct |
1105 ms |
452 KB |
Output is correct |
4 |
Correct |
778 ms |
488 KB |
Output is correct |
5 |
Correct |
697 ms |
400 KB |
Output is correct |
6 |
Correct |
704 ms |
484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
706 ms |
656 KB |
Output is correct |
2 |
Correct |
739 ms |
672 KB |
Output is correct |
3 |
Correct |
1097 ms |
476 KB |
Output is correct |
4 |
Correct |
1011 ms |
492 KB |
Output is correct |
5 |
Correct |
775 ms |
400 KB |
Output is correct |
6 |
Correct |
495 ms |
612 KB |
Output is correct |
7 |
Correct |
438 ms |
616 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
4 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
841 ms |
400 KB |
Output is correct |
12 |
Correct |
499 ms |
696 KB |
Output is correct |
13 |
Correct |
453 ms |
608 KB |
Output is correct |
14 |
Correct |
601 ms |
496 KB |
Output is correct |
15 |
Correct |
44 ms |
400 KB |
Output is correct |
16 |
Correct |
90 ms |
540 KB |
Output is correct |
17 |
Correct |
86 ms |
528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1214 ms |
400 KB |
Output is correct |
2 |
Correct |
662 ms |
400 KB |
Output is correct |
3 |
Correct |
584 ms |
496 KB |
Output is correct |
4 |
Correct |
3 ms |
468 KB |
Output is correct |
5 |
Correct |
5 ms |
464 KB |
Output is correct |
6 |
Correct |
1 ms |
472 KB |
Output is correct |
7 |
Correct |
795 ms |
408 KB |
Output is correct |
8 |
Correct |
1297 ms |
400 KB |
Output is correct |
9 |
Correct |
738 ms |
400 KB |
Output is correct |
10 |
Correct |
513 ms |
400 KB |
Output is correct |
11 |
Correct |
6 ms |
468 KB |
Output is correct |
12 |
Correct |
7 ms |
480 KB |
Output is correct |
13 |
Correct |
5 ms |
468 KB |
Output is correct |
14 |
Correct |
4 ms |
476 KB |
Output is correct |
15 |
Correct |
2 ms |
468 KB |
Output is correct |
16 |
Correct |
492 ms |
488 KB |
Output is correct |
17 |
Correct |
455 ms |
400 KB |
Output is correct |
18 |
Correct |
461 ms |
496 KB |
Output is correct |
19 |
Correct |
755 ms |
400 KB |
Output is correct |
20 |
Correct |
545 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
687 ms |
628 KB |
Output is correct |
2 |
Correct |
546 ms |
612 KB |
Output is correct |
3 |
Correct |
978 ms |
400 KB |
Output is correct |
4 |
Correct |
640 ms |
496 KB |
Output is correct |
5 |
Correct |
862 ms |
400 KB |
Output is correct |
6 |
Correct |
640 ms |
620 KB |
Output is correct |
7 |
Correct |
629 ms |
520 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
5 ms |
476 KB |
Output is correct |
10 |
Correct |
2 ms |
448 KB |
Output is correct |
11 |
Correct |
572 ms |
600 KB |
Output is correct |
12 |
Correct |
497 ms |
492 KB |
Output is correct |
13 |
Correct |
1117 ms |
400 KB |
Output is correct |
14 |
Correct |
829 ms |
488 KB |
Output is correct |
15 |
Correct |
560 ms |
492 KB |
Output is correct |
16 |
Correct |
662 ms |
492 KB |
Output is correct |
17 |
Correct |
590 ms |
488 KB |
Output is correct |
18 |
Correct |
402 ms |
732 KB |
Output is correct |
19 |
Correct |
369 ms |
692 KB |
Output is correct |
20 |
Correct |
583 ms |
492 KB |
Output is correct |
21 |
Correct |
58 ms |
404 KB |
Output is correct |
22 |
Correct |
84 ms |
528 KB |
Output is correct |
23 |
Correct |
109 ms |
528 KB |
Output is correct |
24 |
Correct |
7 ms |
476 KB |
Output is correct |
25 |
Correct |
5 ms |
448 KB |
Output is correct |
26 |
Correct |
6 ms |
468 KB |
Output is correct |
27 |
Correct |
5 ms |
464 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
395 ms |
400 KB |
Output is correct |
30 |
Correct |
490 ms |
492 KB |
Output is correct |
31 |
Correct |
656 ms |
400 KB |
Output is correct |
32 |
Correct |
572 ms |
488 KB |
Output is correct |
33 |
Correct |
500 ms |
400 KB |
Output is correct |
34 |
Correct |
419 ms |
648 KB |
Output is correct |
35 |
Correct |
614 ms |
612 KB |
Output is correct |
36 |
Correct |
573 ms |
684 KB |
Output is correct |
37 |
Correct |
580 ms |
600 KB |
Output is correct |
38 |
Correct |
568 ms |
620 KB |
Output is correct |
39 |
Correct |
606 ms |
684 KB |
Output is correct |
40 |
Correct |
605 ms |
656 KB |
Output is correct |
41 |
Correct |
460 ms |
620 KB |
Output is correct |
42 |
Correct |
67 ms |
528 KB |
Output is correct |
43 |
Correct |
139 ms |
528 KB |
Output is correct |
44 |
Correct |
162 ms |
528 KB |
Output is correct |
45 |
Correct |
199 ms |
624 KB |
Output is correct |
46 |
Correct |
417 ms |
492 KB |
Output is correct |
47 |
Correct |
475 ms |
612 KB |
Output is correct |
48 |
Correct |
86 ms |
648 KB |
Output is correct |
49 |
Correct |
66 ms |
768 KB |
Output is correct |