#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
const int MAX_N=1010;
vector<vi> G;
int in[MAX_N],out[MAX_N];
int it;
void dfs(int u,int p){
in[u]=out[u]=it; it++;
for(auto &v:G[u]){
if(v!=p){
dfs(v,u);
out[u]=max(out[v],out[u]);
}
}
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
G.clear(); G.resize(n+1);
memset(in,0,sizeof in); memset(out,0,sizeof out);
it=0;
for(int i=0;i<n-1;i++){
G[u[i]].push_back(v[i]);
G[v[i]].push_back(u[i]);
}
dfs(0,-1);
vector<int> lab;
for(int i=0;i<n;i++){
lab.push_back(out[i]*1000+in[i]);
}
return lab;
}
int find_next_station(int s, int t, std::vector<int> c) {
int pa=-1,hj=-1;
int lt,rt;
lt=t%1000;
rt=t/1000;
int ls,rs;
ls=s%1000;
rs=s/1000;
for(auto &v:c){
int l,r;
l=v%1000;
r=v/1000;
if(l<=ls && rs<=r){
pa=v;
continue;
}
if(l<=lt && rt<=r) hj=v;
}
//cout<<s<<" "<<t<<" "<<hj<<" "<<pa<<endl;
if(hj==-1) return pa;
return hj;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
416 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=9000 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
400 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=995000 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
572 ms |
688 KB |
Output is correct |
2 |
Correct |
450 ms |
520 KB |
Output is correct |
3 |
Correct |
1251 ms |
400 KB |
Output is correct |
4 |
Correct |
881 ms |
400 KB |
Output is correct |
5 |
Correct |
707 ms |
492 KB |
Output is correct |
6 |
Correct |
618 ms |
624 KB |
Output is correct |
7 |
Correct |
528 ms |
672 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
5 ms |
468 KB |
Output is correct |
10 |
Correct |
2 ms |
468 KB |
Output is correct |
11 |
Correct |
916 ms |
492 KB |
Output is correct |
12 |
Correct |
623 ms |
700 KB |
Output is correct |
13 |
Correct |
754 ms |
696 KB |
Output is correct |
14 |
Correct |
721 ms |
492 KB |
Output is correct |
15 |
Correct |
69 ms |
400 KB |
Output is correct |
16 |
Correct |
70 ms |
528 KB |
Output is correct |
17 |
Correct |
139 ms |
528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1293 ms |
456 KB |
Output is correct |
2 |
Correct |
954 ms |
400 KB |
Output is correct |
3 |
Correct |
588 ms |
412 KB |
Output is correct |
4 |
Correct |
3 ms |
468 KB |
Output is correct |
5 |
Correct |
6 ms |
468 KB |
Output is correct |
6 |
Correct |
2 ms |
468 KB |
Output is correct |
7 |
Correct |
518 ms |
400 KB |
Output is correct |
8 |
Correct |
1267 ms |
468 KB |
Output is correct |
9 |
Correct |
990 ms |
400 KB |
Output is correct |
10 |
Correct |
884 ms |
496 KB |
Output is correct |
11 |
Correct |
6 ms |
468 KB |
Output is correct |
12 |
Correct |
7 ms |
420 KB |
Output is correct |
13 |
Correct |
6 ms |
468 KB |
Output is correct |
14 |
Correct |
5 ms |
468 KB |
Output is correct |
15 |
Correct |
3 ms |
468 KB |
Output is correct |
16 |
Correct |
805 ms |
492 KB |
Output is correct |
17 |
Correct |
783 ms |
400 KB |
Output is correct |
18 |
Correct |
631 ms |
496 KB |
Output is correct |
19 |
Correct |
487 ms |
492 KB |
Output is correct |
20 |
Correct |
819 ms |
400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
610 ms |
656 KB |
Partially correct |
2 |
Partially correct |
568 ms |
608 KB |
Partially correct |
3 |
Partially correct |
1349 ms |
400 KB |
Partially correct |
4 |
Partially correct |
742 ms |
488 KB |
Partially correct |
5 |
Partially correct |
726 ms |
472 KB |
Partially correct |
6 |
Partially correct |
474 ms |
608 KB |
Partially correct |
7 |
Partially correct |
718 ms |
492 KB |
Partially correct |
8 |
Partially correct |
3 ms |
468 KB |
Partially correct |
9 |
Partially correct |
4 ms |
444 KB |
Partially correct |
10 |
Partially correct |
2 ms |
472 KB |
Partially correct |
11 |
Partially correct |
699 ms |
620 KB |
Partially correct |
12 |
Partially correct |
637 ms |
488 KB |
Partially correct |
13 |
Partially correct |
957 ms |
472 KB |
Partially correct |
14 |
Partially correct |
1123 ms |
540 KB |
Partially correct |
15 |
Partially correct |
648 ms |
400 KB |
Partially correct |
16 |
Partially correct |
461 ms |
516 KB |
Partially correct |
17 |
Partially correct |
964 ms |
564 KB |
Partially correct |
18 |
Partially correct |
594 ms |
704 KB |
Partially correct |
19 |
Partially correct |
764 ms |
612 KB |
Partially correct |
20 |
Partially correct |
406 ms |
496 KB |
Partially correct |
21 |
Partially correct |
76 ms |
472 KB |
Partially correct |
22 |
Partially correct |
132 ms |
528 KB |
Partially correct |
23 |
Partially correct |
151 ms |
636 KB |
Partially correct |
24 |
Partially correct |
4 ms |
468 KB |
Partially correct |
25 |
Partially correct |
8 ms |
468 KB |
Partially correct |
26 |
Partially correct |
6 ms |
468 KB |
Partially correct |
27 |
Partially correct |
7 ms |
468 KB |
Partially correct |
28 |
Partially correct |
2 ms |
468 KB |
Partially correct |
29 |
Partially correct |
855 ms |
400 KB |
Partially correct |
30 |
Partially correct |
658 ms |
492 KB |
Partially correct |
31 |
Partially correct |
850 ms |
400 KB |
Partially correct |
32 |
Partially correct |
614 ms |
560 KB |
Partially correct |
33 |
Partially correct |
736 ms |
400 KB |
Partially correct |
34 |
Partially correct |
310 ms |
624 KB |
Partially correct |
35 |
Partially correct |
709 ms |
704 KB |
Partially correct |
36 |
Partially correct |
741 ms |
696 KB |
Partially correct |
37 |
Partially correct |
565 ms |
704 KB |
Partially correct |
38 |
Partially correct |
496 ms |
612 KB |
Partially correct |
39 |
Partially correct |
477 ms |
696 KB |
Partially correct |
40 |
Partially correct |
805 ms |
700 KB |
Partially correct |
41 |
Partially correct |
691 ms |
572 KB |
Partially correct |
42 |
Partially correct |
74 ms |
548 KB |
Partially correct |
43 |
Partially correct |
177 ms |
528 KB |
Partially correct |
44 |
Partially correct |
211 ms |
588 KB |
Partially correct |
45 |
Partially correct |
169 ms |
544 KB |
Partially correct |
46 |
Partially correct |
324 ms |
580 KB |
Partially correct |
47 |
Partially correct |
395 ms |
492 KB |
Partially correct |
48 |
Partially correct |
91 ms |
528 KB |
Partially correct |
49 |
Partially correct |
93 ms |
504 KB |
Partially correct |