@@ -28,31 +28,40 @@ fn main() -> UnitResult {
28
28
// proconio
29
29
#[ proconio_derive:: fastout]
30
30
fn run_proconio ( ) {
31
- use proconio:: input ;
32
- use proconio :: source :: auto :: AutoSource ;
31
+ use proconio:: source :: { line :: LineSource , once :: OnceSource , Source } ;
32
+ use std :: io :: BufReader ;
33
33
34
- let source = AutoSource :: from (
35
- r#"2
34
+ run_proconio_for :: < OnceSource < BufReader < & [ u8 ] > > > ( ) ;
35
+ run_proconio_for :: < LineSource < BufReader < & [ u8 ] > > > ( ) ;
36
+
37
+ #[ proconio_derive:: fastout]
38
+ fn run_proconio_for < ' a , T : Source < BufReader < & ' a [ u8 ] > > + From < & ' a str > > ( ) {
39
+ use proconio:: input;
40
+
41
+ let source = T :: from (
42
+ r#"2
36
43
3 1 2
37
44
6 1 1
38
45
"# ,
39
- ) ;
46
+ ) ;
40
47
41
- input ! {
42
- from source,
43
- n: usize ,
44
- mut plan: [ ( i32 , i32 , i32 ) ; n] , // Vec<(i32, i32, i32)>
48
+ input ! {
49
+ from source,
50
+ n: usize ,
51
+ mut plan: [ ( i32 , i32 , i32 ) ; n] , // Vec<(i32, i32, i32)>
52
+ }
53
+
54
+ plan. insert ( 0 , ( 0 , 0 , 0 ) ) ;
55
+ let yes = plan. windows ( 2 ) . all ( |w| {
56
+ let ( t0, x0, y0) = w[ 0 ] ;
57
+ let ( t1, x1, y1) = w[ 1 ] ;
58
+ let time = t1 - t0;
59
+ let dist = ( x1 - x0) . abs ( ) + ( y1 - y0) . abs ( ) ;
60
+ dist <= time && time % 2 == dist % 2
61
+ } ) ;
62
+ println ! ( "{}" , if yes { "Yes" } else { "No" } ) ;
63
+ assert ! ( yes) ;
45
64
}
46
- plan. insert ( 0 , ( 0 , 0 , 0 ) ) ;
47
- let yes = plan. windows ( 2 ) . all ( |w| {
48
- let ( t0, x0, y0) = w[ 0 ] ;
49
- let ( t1, x1, y1) = w[ 1 ] ;
50
- let time = t1 - t0;
51
- let dist = ( x1 - x0) . abs ( ) + ( y1 - y0) . abs ( ) ;
52
- dist <= time && time % 2 == dist % 2
53
- } ) ;
54
- println ! ( "{}" , if yes { "Yes" } else { "No" } ) ;
55
- assert ! ( yes) ;
56
65
}
57
66
58
67
#[ test]
0 commit comments