#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;}
| ~~^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
549 ms |
1292 KB |
Output is correct |
2 |
Correct |
439 ms |
1248 KB |
Output is correct |
3 |
Correct |
905 ms |
864 KB |
Output is correct |
4 |
Correct |
692 ms |
864 KB |
Output is correct |
5 |
Correct |
634 ms |
1100 KB |
Output is correct |
6 |
Correct |
457 ms |
1080 KB |
Output is correct |
7 |
Correct |
439 ms |
1232 KB |
Output is correct |
8 |
Correct |
3 ms |
988 KB |
Output is correct |
9 |
Correct |
6 ms |
736 KB |
Output is correct |
10 |
Correct |
1 ms |
864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
487 ms |
896 KB |
Output is correct |
2 |
Correct |
639 ms |
904 KB |
Output is correct |
3 |
Correct |
895 ms |
952 KB |
Output is correct |
4 |
Correct |
700 ms |
952 KB |
Output is correct |
5 |
Correct |
656 ms |
948 KB |
Output is correct |
6 |
Correct |
532 ms |
1160 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
564 ms |
1072 KB |
Output is correct |
2 |
Correct |
475 ms |
1072 KB |
Output is correct |
3 |
Correct |
865 ms |
864 KB |
Output is correct |
4 |
Correct |
637 ms |
736 KB |
Output is correct |
5 |
Correct |
561 ms |
1076 KB |
Output is correct |
6 |
Correct |
445 ms |
864 KB |
Output is correct |
7 |
Correct |
451 ms |
1376 KB |
Output is correct |
8 |
Correct |
3 ms |
952 KB |
Output is correct |
9 |
Correct |
5 ms |
736 KB |
Output is correct |
10 |
Correct |
2 ms |
736 KB |
Output is correct |
11 |
Correct |
587 ms |
864 KB |
Output is correct |
12 |
Correct |
490 ms |
1192 KB |
Output is correct |
13 |
Correct |
445 ms |
1076 KB |
Output is correct |
14 |
Correct |
453 ms |
864 KB |
Output is correct |
15 |
Correct |
60 ms |
948 KB |
Output is correct |
16 |
Correct |
57 ms |
736 KB |
Output is correct |
17 |
Correct |
112 ms |
884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1011 ms |
1024 KB |
Output is correct |
2 |
Correct |
771 ms |
864 KB |
Output is correct |
3 |
Correct |
621 ms |
948 KB |
Output is correct |
4 |
Correct |
3 ms |
952 KB |
Output is correct |
5 |
Correct |
5 ms |
736 KB |
Output is correct |
6 |
Correct |
2 ms |
736 KB |
Output is correct |
7 |
Correct |
647 ms |
736 KB |
Output is correct |
8 |
Correct |
978 ms |
896 KB |
Output is correct |
9 |
Correct |
816 ms |
952 KB |
Output is correct |
10 |
Correct |
631 ms |
864 KB |
Output is correct |
11 |
Correct |
6 ms |
948 KB |
Output is correct |
12 |
Correct |
5 ms |
768 KB |
Output is correct |
13 |
Correct |
5 ms |
776 KB |
Output is correct |
14 |
Correct |
4 ms |
736 KB |
Output is correct |
15 |
Correct |
2 ms |
960 KB |
Output is correct |
16 |
Correct |
519 ms |
952 KB |
Output is correct |
17 |
Correct |
544 ms |
864 KB |
Output is correct |
18 |
Correct |
634 ms |
864 KB |
Output is correct |
19 |
Correct |
504 ms |
864 KB |
Output is correct |
20 |
Correct |
639 ms |
864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
619 ms |
1188 KB |
Output is correct |
2 |
Correct |
528 ms |
992 KB |
Output is correct |
3 |
Correct |
875 ms |
1008 KB |
Output is correct |
4 |
Correct |
645 ms |
952 KB |
Output is correct |
5 |
Correct |
623 ms |
864 KB |
Output is correct |
6 |
Correct |
493 ms |
864 KB |
Output is correct |
7 |
Correct |
587 ms |
992 KB |
Output is correct |
8 |
Correct |
3 ms |
736 KB |
Output is correct |
9 |
Correct |
5 ms |
864 KB |
Output is correct |
10 |
Correct |
2 ms |
948 KB |
Output is correct |
11 |
Correct |
498 ms |
864 KB |
Output is correct |
12 |
Correct |
570 ms |
1164 KB |
Output is correct |
13 |
Correct |
1020 ms |
864 KB |
Output is correct |
14 |
Correct |
887 ms |
1104 KB |
Output is correct |
15 |
Correct |
553 ms |
864 KB |
Output is correct |
16 |
Correct |
529 ms |
860 KB |
Output is correct |
17 |
Correct |
731 ms |
864 KB |
Output is correct |
18 |
Correct |
568 ms |
1000 KB |
Output is correct |
19 |
Correct |
475 ms |
864 KB |
Output is correct |
20 |
Correct |
529 ms |
736 KB |
Output is correct |
21 |
Correct |
54 ms |
736 KB |
Output is correct |
22 |
Correct |
68 ms |
864 KB |
Output is correct |
23 |
Correct |
120 ms |
904 KB |
Output is correct |
24 |
Correct |
6 ms |
736 KB |
Output is correct |
25 |
Correct |
8 ms |
864 KB |
Output is correct |
26 |
Correct |
7 ms |
944 KB |
Output is correct |
27 |
Correct |
5 ms |
736 KB |
Output is correct |
28 |
Correct |
2 ms |
864 KB |
Output is correct |
29 |
Correct |
669 ms |
864 KB |
Output is correct |
30 |
Correct |
541 ms |
864 KB |
Output is correct |
31 |
Correct |
664 ms |
864 KB |
Output is correct |
32 |
Correct |
514 ms |
992 KB |
Output is correct |
33 |
Correct |
630 ms |
876 KB |
Output is correct |
34 |
Correct |
413 ms |
992 KB |
Output is correct |
35 |
Correct |
486 ms |
1004 KB |
Output is correct |
36 |
Correct |
484 ms |
1204 KB |
Output is correct |
37 |
Correct |
442 ms |
1012 KB |
Output is correct |
38 |
Correct |
505 ms |
988 KB |
Output is correct |
39 |
Correct |
516 ms |
940 KB |
Output is correct |
40 |
Correct |
527 ms |
1132 KB |
Output is correct |
41 |
Correct |
499 ms |
1084 KB |
Output is correct |
42 |
Correct |
60 ms |
864 KB |
Output is correct |
43 |
Correct |
139 ms |
864 KB |
Output is correct |
44 |
Correct |
163 ms |
864 KB |
Output is correct |
45 |
Correct |
157 ms |
736 KB |
Output is correct |
46 |
Correct |
322 ms |
864 KB |
Output is correct |
47 |
Correct |
334 ms |
1112 KB |
Output is correct |
48 |
Correct |
55 ms |
1100 KB |
Output is correct |
49 |
Correct |
56 ms |
992 KB |
Output is correct |