#include<bits/stdc++.h>
#include "stations.h"
using namespace std;
vector<int> adj[1005];
int dtime;
/// in-stvis unda vicode out-ebi , out-stvis in-ebi
void dfs(int u , int h , vector<int> &R ,int p ){
if(h) R[u]= dtime++;
for(int v : adj[u])if(v != p)dfs(v ,h^1 , R , u);
if(!h) R[u] = dtime++;
}
vector<int> label(int n , int k ,vector<int> u , vector<int> v){
for(int i = 0; i < n; ++i) adj[i].clear();
for(int i = 0; i < n-1; ++i) adj[u[i]].emplace_back(v[i]) , adj[v[i]].emplace_back(u[i]);
vector<int> R(n);
dtime =0;
dfs(0 , 0 , R ,-1);
return R;
}
/// (in1 , out1) in = out0 + 1
/// (in0 , out0) out0 = in1 - 1;
int find_next_station(int s , int t , vector<int> c){
/// s-in
if(s < c[0]){
int cur = s;
for(int x: c){
if(cur < t && t <= x) return x;
cur = x;
}
return c.back(); /// parent
} else {
/// s out
for(int i = 0; i < c.size(); ++i){
if(i == c.size() - 1) {if(c[i] <= t && t <= s) return c[i]; continue;}
if(c[i] <= t && t < c[i + 1]) return c[i];
}
/// parent
return c[0];
}
}
/*
int main (){
cin >> n;
for(int i =1; i < n; ++i){
int u , v; cin >> u>> v;
adj[u].emplace_back(v); adj[v].emplace_back(u);
}
vector<int> k = label(n , 1 , {3} , {3});
cout << find_next_station(1 , 3 , {3 , 2 ,0}) << endl;
}
*/
//int main (){}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:33:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for(int i = 0; i < c.size(); ++i){
| ~~^~~~~~~~~~
stations.cpp:34:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | if(i == c.size() - 1) {if(c[i] <= t && t <= s) return c[i]; continue;}
| ~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
611 ms |
992 KB |
Output is correct |
2 |
Correct |
494 ms |
992 KB |
Output is correct |
3 |
Correct |
996 ms |
864 KB |
Output is correct |
4 |
Correct |
726 ms |
864 KB |
Output is correct |
5 |
Correct |
633 ms |
896 KB |
Output is correct |
6 |
Correct |
451 ms |
992 KB |
Output is correct |
7 |
Correct |
580 ms |
992 KB |
Output is correct |
8 |
Correct |
3 ms |
864 KB |
Output is correct |
9 |
Correct |
4 ms |
864 KB |
Output is correct |
10 |
Correct |
1 ms |
736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
539 ms |
884 KB |
Output is correct |
2 |
Correct |
706 ms |
864 KB |
Output is correct |
3 |
Correct |
937 ms |
736 KB |
Output is correct |
4 |
Correct |
678 ms |
864 KB |
Output is correct |
5 |
Correct |
608 ms |
736 KB |
Output is correct |
6 |
Correct |
533 ms |
736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
618 ms |
864 KB |
Output is correct |
2 |
Correct |
561 ms |
992 KB |
Output is correct |
3 |
Correct |
976 ms |
864 KB |
Output is correct |
4 |
Correct |
749 ms |
864 KB |
Output is correct |
5 |
Correct |
686 ms |
864 KB |
Output is correct |
6 |
Correct |
556 ms |
992 KB |
Output is correct |
7 |
Correct |
441 ms |
1408 KB |
Output is correct |
8 |
Correct |
3 ms |
956 KB |
Output is correct |
9 |
Correct |
5 ms |
864 KB |
Output is correct |
10 |
Correct |
2 ms |
884 KB |
Output is correct |
11 |
Correct |
636 ms |
736 KB |
Output is correct |
12 |
Correct |
524 ms |
992 KB |
Output is correct |
13 |
Correct |
612 ms |
1372 KB |
Output is correct |
14 |
Correct |
510 ms |
736 KB |
Output is correct |
15 |
Correct |
71 ms |
928 KB |
Output is correct |
16 |
Correct |
92 ms |
912 KB |
Output is correct |
17 |
Correct |
104 ms |
864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
994 ms |
1024 KB |
Output is correct |
2 |
Correct |
795 ms |
736 KB |
Output is correct |
3 |
Correct |
769 ms |
884 KB |
Output is correct |
4 |
Correct |
3 ms |
736 KB |
Output is correct |
5 |
Correct |
5 ms |
736 KB |
Output is correct |
6 |
Correct |
2 ms |
864 KB |
Output is correct |
7 |
Correct |
649 ms |
864 KB |
Output is correct |
8 |
Correct |
896 ms |
864 KB |
Output is correct |
9 |
Correct |
783 ms |
864 KB |
Output is correct |
10 |
Correct |
599 ms |
864 KB |
Output is correct |
11 |
Correct |
6 ms |
864 KB |
Output is correct |
12 |
Correct |
5 ms |
960 KB |
Output is correct |
13 |
Correct |
5 ms |
864 KB |
Output is correct |
14 |
Correct |
5 ms |
736 KB |
Output is correct |
15 |
Correct |
2 ms |
864 KB |
Output is correct |
16 |
Correct |
570 ms |
864 KB |
Output is correct |
17 |
Correct |
507 ms |
864 KB |
Output is correct |
18 |
Correct |
477 ms |
948 KB |
Output is correct |
19 |
Correct |
519 ms |
948 KB |
Output is correct |
20 |
Correct |
545 ms |
992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
556 ms |
1076 KB |
Output is correct |
2 |
Correct |
477 ms |
1092 KB |
Output is correct |
3 |
Correct |
854 ms |
1120 KB |
Output is correct |
4 |
Correct |
677 ms |
948 KB |
Output is correct |
5 |
Correct |
620 ms |
952 KB |
Output is correct |
6 |
Correct |
438 ms |
1240 KB |
Output is correct |
7 |
Correct |
473 ms |
884 KB |
Output is correct |
8 |
Correct |
3 ms |
736 KB |
Output is correct |
9 |
Correct |
5 ms |
944 KB |
Output is correct |
10 |
Correct |
1 ms |
864 KB |
Output is correct |
11 |
Correct |
457 ms |
1120 KB |
Output is correct |
12 |
Correct |
524 ms |
864 KB |
Output is correct |
13 |
Correct |
838 ms |
840 KB |
Output is correct |
14 |
Correct |
640 ms |
940 KB |
Output is correct |
15 |
Correct |
572 ms |
864 KB |
Output is correct |
16 |
Correct |
455 ms |
864 KB |
Output is correct |
17 |
Correct |
565 ms |
956 KB |
Output is correct |
18 |
Correct |
470 ms |
1232 KB |
Output is correct |
19 |
Correct |
481 ms |
1332 KB |
Output is correct |
20 |
Correct |
444 ms |
908 KB |
Output is correct |
21 |
Correct |
55 ms |
968 KB |
Output is correct |
22 |
Correct |
69 ms |
864 KB |
Output is correct |
23 |
Correct |
110 ms |
884 KB |
Output is correct |
24 |
Correct |
6 ms |
960 KB |
Output is correct |
25 |
Correct |
7 ms |
952 KB |
Output is correct |
26 |
Correct |
5 ms |
736 KB |
Output is correct |
27 |
Correct |
5 ms |
864 KB |
Output is correct |
28 |
Correct |
2 ms |
1084 KB |
Output is correct |
29 |
Correct |
680 ms |
952 KB |
Output is correct |
30 |
Correct |
534 ms |
952 KB |
Output is correct |
31 |
Correct |
538 ms |
948 KB |
Output is correct |
32 |
Correct |
486 ms |
948 KB |
Output is correct |
33 |
Correct |
500 ms |
736 KB |
Output is correct |
34 |
Correct |
321 ms |
864 KB |
Output is correct |
35 |
Correct |
415 ms |
1112 KB |
Output is correct |
36 |
Correct |
437 ms |
1028 KB |
Output is correct |
37 |
Correct |
452 ms |
1104 KB |
Output is correct |
38 |
Correct |
469 ms |
1236 KB |
Output is correct |
39 |
Correct |
442 ms |
1120 KB |
Output is correct |
40 |
Correct |
445 ms |
1120 KB |
Output is correct |
41 |
Correct |
453 ms |
1356 KB |
Output is correct |
42 |
Correct |
67 ms |
1116 KB |
Output is correct |
43 |
Correct |
105 ms |
736 KB |
Output is correct |
44 |
Correct |
136 ms |
880 KB |
Output is correct |
45 |
Correct |
160 ms |
864 KB |
Output is correct |
46 |
Correct |
316 ms |
736 KB |
Output is correct |
47 |
Correct |
330 ms |
992 KB |
Output is correct |
48 |
Correct |
65 ms |
992 KB |
Output is correct |
49 |
Correct |
61 ms |
864 KB |
Output is correct |