Skip to content

Commit b9c7218

Browse files
committed
Test both OnceSource and LineSource instead of AutoSource
1 parent 797c9ff commit b9c7218

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

src/main.rs

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,41 @@ fn main() -> UnitResult {
2929
// https://atcoder.jp/contests/abs/fasks/arc089_a
3030

3131
// proconio
32-
#[proconio::fastout]
3332
fn run_proconio() {
34-
use proconio::input;
35-
use proconio::source::auto::AutoSource;
33+
use proconio::source::{line::LineSource, once::OnceSource, Source};
34+
use std::io::BufReader;
3635

37-
let source = AutoSource::from(
38-
r#"2
36+
run_proconio_for::<OnceSource<BufReader<&[u8]>>>();
37+
run_proconio_for::<LineSource<BufReader<&[u8]>>>();
38+
39+
#[proconio::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
3945
3 1 2
4046
6 1 1
4147
"#,
42-
);
43-
44-
input! {
45-
from source,
46-
n: usize,
47-
mut plan: [(i32, i32, i32); n], // Vec<(i32, i32, i32)>
48+
);
49+
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);
4866
}
49-
plan.insert(0, (0, 0, 0));
50-
let yes = plan.windows(2).all(|w| {
51-
let (t0, x0, y0) = w[0];
52-
let (t1, x1, y1) = w[1];
53-
let time = t1 - t0;
54-
let dist = (x1 - x0).abs() + (y1 - y0).abs();
55-
dist <= time && time % 2 == dist % 2
56-
});
57-
println!("{}", if yes { "Yes" } else { "No" });
58-
assert!(yes);
5967
}
6068

6169
#[test]

0 commit comments

Comments
 (0)