Skip to content

Commit 83a6087

Browse files
committedAug 6, 2019
Test both OnceSource and LineSource instead of AutoSource
1 parent 180417d commit 83a6087

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed
 

‎src/main.rs

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,40 @@ fn main() -> UnitResult {
2828
// proconio
2929
#[proconio_derive::fastout]
3030
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;
3333

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
3643
3 1 2
3744
6 1 1
3845
"#,
39-
);
46+
);
4047

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);
4564
}
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);
5665
}
5766

5867
#[test]

0 commit comments

Comments
 (0)