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