From 2d401c651b93cf193cf5f0960a8878789f3cbb9b Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Thu, 19 Dec 2019 19:45:50 +0900 Subject: [PATCH 01/39] Add a test for ABC129-F --- examples/abc129-f.rs | 132 ++++++++++++++++++ examples/tests.ron | 4 + examples/testsets/abc129-f/in/sample_01.txt | 1 + examples/testsets/abc129-f/in/sample_02.txt | 1 + examples/testsets/abc129-f/in/sample_03.txt | 1 + .../testsets/abc129-f/in/sub1_killer_01.txt | 1 + .../testsets/abc129-f/in/sub1_killer_02.txt | 1 + .../testsets/abc129-f/in/sub1_killer_03.txt | 1 + .../testsets/abc129-f/in/sub1_killer_04.txt | 1 + .../testsets/abc129-f/in/sub1_killer_05.txt | 1 + .../testsets/abc129-f/in/sub1_killer_06.txt | 1 + .../testsets/abc129-f/in/sub1_killer_07.txt | 1 + .../testsets/abc129-f/in/sub1_large_01.txt | 1 + .../testsets/abc129-f/in/sub1_large_02.txt | 1 + .../testsets/abc129-f/in/sub1_large_03.txt | 1 + .../testsets/abc129-f/in/sub1_large_04.txt | 1 + .../testsets/abc129-f/in/sub1_large_05.txt | 1 + .../testsets/abc129-f/in/sub1_large_06.txt | 1 + .../testsets/abc129-f/in/sub1_large_07.txt | 1 + .../testsets/abc129-f/in/sub1_large_08.txt | 1 + .../testsets/abc129-f/in/sub1_large_09.txt | 1 + .../testsets/abc129-f/in/sub1_rand_01.txt | 1 + .../testsets/abc129-f/in/sub1_rand_02.txt | 1 + .../testsets/abc129-f/in/sub1_rand_03.txt | 1 + .../testsets/abc129-f/in/sub1_rand_04.txt | 1 + .../testsets/abc129-f/in/sub1_rand_05.txt | 1 + .../testsets/abc129-f/in/sub1_rand_06.txt | 1 + .../testsets/abc129-f/in/sub1_rand_07.txt | 1 + .../testsets/abc129-f/in/sub1_rand_08.txt | 1 + .../testsets/abc129-f/in/sub1_rand_09.txt | 1 + .../testsets/abc129-f/in/sub1_rand_10.txt | 1 + .../testsets/abc129-f/in/sub1_small_01.txt | 1 + .../testsets/abc129-f/in/sub1_small_02.txt | 1 + .../testsets/abc129-f/in/sub1_small_03.txt | 1 + .../testsets/abc129-f/in/sub1_small_04.txt | 1 + .../testsets/abc129-f/in/sub1_small_05.txt | 1 + .../testsets/abc129-f/in/sub1_small_06.txt | 1 + examples/testsets/abc129-f/out/sample_01.txt | 1 + examples/testsets/abc129-f/out/sample_02.txt | 1 + examples/testsets/abc129-f/out/sample_03.txt | 1 + .../testsets/abc129-f/out/sub1_killer_01.txt | 1 + .../testsets/abc129-f/out/sub1_killer_02.txt | 1 + .../testsets/abc129-f/out/sub1_killer_03.txt | 1 + .../testsets/abc129-f/out/sub1_killer_04.txt | 1 + .../testsets/abc129-f/out/sub1_killer_05.txt | 1 + .../testsets/abc129-f/out/sub1_killer_06.txt | 1 + .../testsets/abc129-f/out/sub1_killer_07.txt | 1 + .../testsets/abc129-f/out/sub1_large_01.txt | 1 + .../testsets/abc129-f/out/sub1_large_02.txt | 1 + .../testsets/abc129-f/out/sub1_large_03.txt | 1 + .../testsets/abc129-f/out/sub1_large_04.txt | 1 + .../testsets/abc129-f/out/sub1_large_05.txt | 1 + .../testsets/abc129-f/out/sub1_large_06.txt | 1 + .../testsets/abc129-f/out/sub1_large_07.txt | 1 + .../testsets/abc129-f/out/sub1_large_08.txt | 1 + .../testsets/abc129-f/out/sub1_large_09.txt | 1 + .../testsets/abc129-f/out/sub1_rand_01.txt | 1 + .../testsets/abc129-f/out/sub1_rand_02.txt | 1 + .../testsets/abc129-f/out/sub1_rand_03.txt | 1 + .../testsets/abc129-f/out/sub1_rand_04.txt | 1 + .../testsets/abc129-f/out/sub1_rand_05.txt | 1 + .../testsets/abc129-f/out/sub1_rand_06.txt | 1 + .../testsets/abc129-f/out/sub1_rand_07.txt | 1 + .../testsets/abc129-f/out/sub1_rand_08.txt | 1 + .../testsets/abc129-f/out/sub1_rand_09.txt | 1 + .../testsets/abc129-f/out/sub1_rand_10.txt | 1 + .../testsets/abc129-f/out/sub1_small_01.txt | 1 + .../testsets/abc129-f/out/sub1_small_02.txt | 1 + .../testsets/abc129-f/out/sub1_small_03.txt | 1 + .../testsets/abc129-f/out/sub1_small_04.txt | 1 + .../testsets/abc129-f/out/sub1_small_05.txt | 1 + .../testsets/abc129-f/out/sub1_small_06.txt | 1 + 72 files changed, 206 insertions(+) create mode 100644 examples/abc129-f.rs create mode 100644 examples/testsets/abc129-f/in/sample_01.txt create mode 100644 examples/testsets/abc129-f/in/sample_02.txt create mode 100644 examples/testsets/abc129-f/in/sample_03.txt create mode 100644 examples/testsets/abc129-f/in/sub1_killer_01.txt create mode 100644 examples/testsets/abc129-f/in/sub1_killer_02.txt create mode 100644 examples/testsets/abc129-f/in/sub1_killer_03.txt create mode 100644 examples/testsets/abc129-f/in/sub1_killer_04.txt create mode 100644 examples/testsets/abc129-f/in/sub1_killer_05.txt create mode 100644 examples/testsets/abc129-f/in/sub1_killer_06.txt create mode 100644 examples/testsets/abc129-f/in/sub1_killer_07.txt create mode 100644 examples/testsets/abc129-f/in/sub1_large_01.txt create mode 100644 examples/testsets/abc129-f/in/sub1_large_02.txt create mode 100644 examples/testsets/abc129-f/in/sub1_large_03.txt create mode 100644 examples/testsets/abc129-f/in/sub1_large_04.txt create mode 100644 examples/testsets/abc129-f/in/sub1_large_05.txt create mode 100644 examples/testsets/abc129-f/in/sub1_large_06.txt create mode 100644 examples/testsets/abc129-f/in/sub1_large_07.txt create mode 100644 examples/testsets/abc129-f/in/sub1_large_08.txt create mode 100644 examples/testsets/abc129-f/in/sub1_large_09.txt create mode 100644 examples/testsets/abc129-f/in/sub1_rand_01.txt create mode 100644 examples/testsets/abc129-f/in/sub1_rand_02.txt create mode 100644 examples/testsets/abc129-f/in/sub1_rand_03.txt create mode 100644 examples/testsets/abc129-f/in/sub1_rand_04.txt create mode 100644 examples/testsets/abc129-f/in/sub1_rand_05.txt create mode 100644 examples/testsets/abc129-f/in/sub1_rand_06.txt create mode 100644 examples/testsets/abc129-f/in/sub1_rand_07.txt create mode 100644 examples/testsets/abc129-f/in/sub1_rand_08.txt create mode 100644 examples/testsets/abc129-f/in/sub1_rand_09.txt create mode 100644 examples/testsets/abc129-f/in/sub1_rand_10.txt create mode 100644 examples/testsets/abc129-f/in/sub1_small_01.txt create mode 100644 examples/testsets/abc129-f/in/sub1_small_02.txt create mode 100644 examples/testsets/abc129-f/in/sub1_small_03.txt create mode 100644 examples/testsets/abc129-f/in/sub1_small_04.txt create mode 100644 examples/testsets/abc129-f/in/sub1_small_05.txt create mode 100644 examples/testsets/abc129-f/in/sub1_small_06.txt create mode 100644 examples/testsets/abc129-f/out/sample_01.txt create mode 100644 examples/testsets/abc129-f/out/sample_02.txt create mode 100644 examples/testsets/abc129-f/out/sample_03.txt create mode 100644 examples/testsets/abc129-f/out/sub1_killer_01.txt create mode 100644 examples/testsets/abc129-f/out/sub1_killer_02.txt create mode 100644 examples/testsets/abc129-f/out/sub1_killer_03.txt create mode 100644 examples/testsets/abc129-f/out/sub1_killer_04.txt create mode 100644 examples/testsets/abc129-f/out/sub1_killer_05.txt create mode 100644 examples/testsets/abc129-f/out/sub1_killer_06.txt create mode 100644 examples/testsets/abc129-f/out/sub1_killer_07.txt create mode 100644 examples/testsets/abc129-f/out/sub1_large_01.txt create mode 100644 examples/testsets/abc129-f/out/sub1_large_02.txt create mode 100644 examples/testsets/abc129-f/out/sub1_large_03.txt create mode 100644 examples/testsets/abc129-f/out/sub1_large_04.txt create mode 100644 examples/testsets/abc129-f/out/sub1_large_05.txt create mode 100644 examples/testsets/abc129-f/out/sub1_large_06.txt create mode 100644 examples/testsets/abc129-f/out/sub1_large_07.txt create mode 100644 examples/testsets/abc129-f/out/sub1_large_08.txt create mode 100644 examples/testsets/abc129-f/out/sub1_large_09.txt create mode 100644 examples/testsets/abc129-f/out/sub1_rand_01.txt create mode 100644 examples/testsets/abc129-f/out/sub1_rand_02.txt create mode 100644 examples/testsets/abc129-f/out/sub1_rand_03.txt create mode 100644 examples/testsets/abc129-f/out/sub1_rand_04.txt create mode 100644 examples/testsets/abc129-f/out/sub1_rand_05.txt create mode 100644 examples/testsets/abc129-f/out/sub1_rand_06.txt create mode 100644 examples/testsets/abc129-f/out/sub1_rand_07.txt create mode 100644 examples/testsets/abc129-f/out/sub1_rand_08.txt create mode 100644 examples/testsets/abc129-f/out/sub1_rand_09.txt create mode 100644 examples/testsets/abc129-f/out/sub1_rand_10.txt create mode 100644 examples/testsets/abc129-f/out/sub1_small_01.txt create mode 100644 examples/testsets/abc129-f/out/sub1_small_02.txt create mode 100644 examples/testsets/abc129-f/out/sub1_small_03.txt create mode 100644 examples/testsets/abc129-f/out/sub1_small_04.txt create mode 100644 examples/testsets/abc129-f/out/sub1_small_05.txt create mode 100644 examples/testsets/abc129-f/out/sub1_small_06.txt diff --git a/examples/abc129-f.rs b/examples/abc129-f.rs new file mode 100644 index 0000000..019849a --- /dev/null +++ b/examples/abc129-f.rs @@ -0,0 +1,132 @@ +// https://atcoder.jp/contests/abc129/tasks/abc129_f + +use derive_more::Display; +use ndarray::{array, Array2, LinalgScalar}; +use num::{PrimInt, Unsigned}; +use num_derive::{One, Zero}; + +use std::cell::Cell; +use std::cmp; +use std::ops::{Add, Div, Mul, Sub}; + +fn main() { + // use std::io::{self, Read as _}; + // + // let mut input = "".to_owned(); + // io::stdin().read_to_string(&mut input).unwrap(); + // let mut input = input.split_whitespace(); + // macro_rules! read { + // ([$t:tt; $n:expr]) => { + // (0..$n).map(|_| read!($t)).collect::>() + // }; + // (($($t:tt),+)) => { + // ($(read!($t)),*) + // }; + // (_1based) => { + // read!(usize) - 1 + // }; + // (_bytes) => { + // read!(String).into_bytes() + // }; + // ($ty:ty) => { + // input.next().unwrap().parse::<$ty>().unwrap() + // }; + // } + // + // let (l, a, b, m) = read!((u64, u64, u64, u64)); + + use proconio::input; + + input! { + l: u64, + a: u64, + b: u64, + m: u64, + } + + MOD.with(|cell| cell.set(m)); + + let count = |d| -> _ { + let count = |sup: u64| cmp::min(sup.saturating_sub(a + 1) / b + u64::from(b < sup), l); + count(10u64.pow(d)) - count(10u64.pow(d - 1)) + }; + + let ans = (1..=18).fold(array![[Z(0), Z::checked(a), Z(1)]], |acc, d| { + acc.dot( + &array![ + [Z::checked(10u64.pow(d)), Z(0), Z(0)], + [Z(1), Z(1), Z(0)], + [Z(0), Z::checked(b), Z(1)], + ] + .matrix_power(count(d)), + ) + })[(0, 0)]; + println!("{}", ans); +} + +trait Array2Ext { + fn matrix_power(&self, exp: E) -> Self; +} + +impl Array2Ext for Array2 { + fn matrix_power(&self, exp: E) -> Self { + let (mut base, mut exp, mut acc) = (self.clone(), exp, Self::eye(self.nrows())); + while exp > E::zero() { + if (exp & E::one()) == E::one() { + acc = acc.dot(&base); + } + exp = exp / (E::one() + E::one()); + base = base.dot(&base); + } + acc + } +} + +thread_local! { + static MOD: Cell = Cell::new(0); +} + +#[derive(Zero, One, Display, Debug, Clone, Copy)] +struct Z(u64); + +impl Z { + fn checked(mut val: u64) -> Self { + let modulus = MOD.with(Cell::get); + if val >= modulus { + val %= modulus; + } + Self(val) + } +} + +impl Add for Z { + type Output = Self; + + fn add(self, rhs: Self) -> Self { + Self::checked(self.0 + rhs.0) + } +} + +impl Sub for Z { + type Output = Self; + + fn sub(self, _: Self) -> Self { + unreachable!("should not be performed") + } +} + +impl Mul for Z { + type Output = Self; + + fn mul(self, rhs: Self) -> Self { + Self::checked(self.0 * rhs.0) + } +} + +impl Div for Z { + type Output = Self; + + fn div(self, _: Self) -> Self { + unreachable!("should not be performed") + } +} diff --git a/examples/tests.ron b/examples/tests.ron index c96e7e5..49b4f7a 100644 --- a/examples/tests.ron +++ b/examples/tests.ron @@ -43,6 +43,10 @@ name: "ABC120: D - Decayed Bridges", matching: ExactWords, ), + "abc129-f": ( + name: "ABC129: F - Takahashi's Basics in Education and Learning", + matching: ExactWords, + ), "abc142-d": ( name: "ABC124: D - Disjoint Set of Common Divisors", matching: ExactWords, diff --git a/examples/testsets/abc129-f/in/sample_01.txt b/examples/testsets/abc129-f/in/sample_01.txt new file mode 100644 index 0000000..42e1211 --- /dev/null +++ b/examples/testsets/abc129-f/in/sample_01.txt @@ -0,0 +1 @@ +5 3 4 10007 diff --git a/examples/testsets/abc129-f/in/sample_02.txt b/examples/testsets/abc129-f/in/sample_02.txt new file mode 100644 index 0000000..969f9fc --- /dev/null +++ b/examples/testsets/abc129-f/in/sample_02.txt @@ -0,0 +1 @@ +4 8 1 1000000 diff --git a/examples/testsets/abc129-f/in/sample_03.txt b/examples/testsets/abc129-f/in/sample_03.txt new file mode 100644 index 0000000..7cb7ba4 --- /dev/null +++ b/examples/testsets/abc129-f/in/sample_03.txt @@ -0,0 +1 @@ +107 10000000000007 1000000000000007 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_killer_01.txt b/examples/testsets/abc129-f/in/sub1_killer_01.txt new file mode 100644 index 0000000..cb59cb9 --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_killer_01.txt @@ -0,0 +1 @@ +2500000000000 4 4 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_killer_02.txt b/examples/testsets/abc129-f/in/sub1_killer_02.txt new file mode 100644 index 0000000..b1582fc --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_killer_02.txt @@ -0,0 +1 @@ +99982444353 100 4 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_killer_03.txt b/examples/testsets/abc129-f/in/sub1_killer_03.txt new file mode 100644 index 0000000..8067387 --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_killer_03.txt @@ -0,0 +1 @@ +333333333333333333 3 3 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_killer_04.txt b/examples/testsets/abc129-f/in/sub1_killer_04.txt new file mode 100644 index 0000000..caf49ce --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_killer_04.txt @@ -0,0 +1 @@ +1 999999999999999999 999999999999999999 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_killer_05.txt b/examples/testsets/abc129-f/in/sub1_killer_05.txt new file mode 100644 index 0000000..8dad240 --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_killer_05.txt @@ -0,0 +1 @@ +998244353 629149506971940504 319836804 14876851 diff --git a/examples/testsets/abc129-f/in/sub1_killer_06.txt b/examples/testsets/abc129-f/in/sub1_killer_06.txt new file mode 100644 index 0000000..ee45d99 --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_killer_06.txt @@ -0,0 +1 @@ +999918203 4248 723308865 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_killer_07.txt b/examples/testsets/abc129-f/in/sub1_killer_07.txt new file mode 100644 index 0000000..7c691d6 --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_killer_07.txt @@ -0,0 +1 @@ +100000000000 6 231 25200 diff --git a/examples/testsets/abc129-f/in/sub1_large_01.txt b/examples/testsets/abc129-f/in/sub1_large_01.txt new file mode 100644 index 0000000..1bf1e1b --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_large_01.txt @@ -0,0 +1 @@ +999999999999999999 1 1 1000000000 diff --git a/examples/testsets/abc129-f/in/sub1_large_02.txt b/examples/testsets/abc129-f/in/sub1_large_02.txt new file mode 100644 index 0000000..09de7a1 --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_large_02.txt @@ -0,0 +1 @@ +11837588 221218607 84473754642 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_large_03.txt b/examples/testsets/abc129-f/in/sub1_large_03.txt new file mode 100644 index 0000000..9d8ee74 --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_large_03.txt @@ -0,0 +1 @@ +81074056293 7047569542 12261087 29999997 diff --git a/examples/testsets/abc129-f/in/sub1_large_04.txt b/examples/testsets/abc129-f/in/sub1_large_04.txt new file mode 100644 index 0000000..b484c04 --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_large_04.txt @@ -0,0 +1 @@ +999999999999999999 1 1 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_large_05.txt b/examples/testsets/abc129-f/in/sub1_large_05.txt new file mode 100644 index 0000000..98320ad --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_large_05.txt @@ -0,0 +1 @@ +328613923524538 40980 3031 999999999 diff --git a/examples/testsets/abc129-f/in/sub1_large_06.txt b/examples/testsets/abc129-f/in/sub1_large_06.txt new file mode 100644 index 0000000..111af0c --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_large_06.txt @@ -0,0 +1 @@ +10914883567412 1570 62840 99999999 diff --git a/examples/testsets/abc129-f/in/sub1_large_07.txt b/examples/testsets/abc129-f/in/sub1_large_07.txt new file mode 100644 index 0000000..502b824 --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_large_07.txt @@ -0,0 +1 @@ +1448057007031098 11 690 881005587 diff --git a/examples/testsets/abc129-f/in/sub1_large_08.txt b/examples/testsets/abc129-f/in/sub1_large_08.txt new file mode 100644 index 0000000..e3210cc --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_large_08.txt @@ -0,0 +1 @@ +74358445905354 29310 13448 147413419 diff --git a/examples/testsets/abc129-f/in/sub1_large_09.txt b/examples/testsets/abc129-f/in/sub1_large_09.txt new file mode 100644 index 0000000..953a3a1 --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_large_09.txt @@ -0,0 +1 @@ +120900801167206 994 8061 387420489 diff --git a/examples/testsets/abc129-f/in/sub1_rand_01.txt b/examples/testsets/abc129-f/in/sub1_rand_01.txt new file mode 100644 index 0000000..bf29c51 --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_rand_01.txt @@ -0,0 +1 @@ +1380800559 8 721124722 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_rand_02.txt b/examples/testsets/abc129-f/in/sub1_rand_02.txt new file mode 100644 index 0000000..ce81814 --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_rand_02.txt @@ -0,0 +1 @@ +105301221317 8 9457145 999999999 diff --git a/examples/testsets/abc129-f/in/sub1_rand_03.txt b/examples/testsets/abc129-f/in/sub1_rand_03.txt new file mode 100644 index 0000000..a115e1e --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_rand_03.txt @@ -0,0 +1 @@ +53562851 12672052437647 18553359394 99999999 diff --git a/examples/testsets/abc129-f/in/sub1_rand_04.txt b/examples/testsets/abc129-f/in/sub1_rand_04.txt new file mode 100644 index 0000000..74d7f96 --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_rand_04.txt @@ -0,0 +1 @@ +7343 44375369427231 136194167038156 841293953 diff --git a/examples/testsets/abc129-f/in/sub1_rand_05.txt b/examples/testsets/abc129-f/in/sub1_rand_05.txt new file mode 100644 index 0000000..ec7780e --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_rand_05.txt @@ -0,0 +1 @@ +234481 8715183188079 4262710627175 9999999 diff --git a/examples/testsets/abc129-f/in/sub1_rand_06.txt b/examples/testsets/abc129-f/in/sub1_rand_06.txt new file mode 100644 index 0000000..96df56c --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_rand_06.txt @@ -0,0 +1 @@ +335 2647488178484 2976541338296614 999918169 diff --git a/examples/testsets/abc129-f/in/sub1_rand_07.txt b/examples/testsets/abc129-f/in/sub1_rand_07.txt new file mode 100644 index 0000000..c352840 --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_rand_07.txt @@ -0,0 +1 @@ +2508131942730888 5 397 387420489 diff --git a/examples/testsets/abc129-f/in/sub1_rand_08.txt b/examples/testsets/abc129-f/in/sub1_rand_08.txt new file mode 100644 index 0000000..f2eebd5 --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_rand_08.txt @@ -0,0 +1 @@ +151407055 44693807224027 6603923461 1000000000 diff --git a/examples/testsets/abc129-f/in/sub1_rand_09.txt b/examples/testsets/abc129-f/in/sub1_rand_09.txt new file mode 100644 index 0000000..baf9c53 --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_rand_09.txt @@ -0,0 +1 @@ +17544042820 3 56987735 387420489 diff --git a/examples/testsets/abc129-f/in/sub1_rand_10.txt b/examples/testsets/abc129-f/in/sub1_rand_10.txt new file mode 100644 index 0000000..ba0c84d --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_rand_10.txt @@ -0,0 +1 @@ +355391 6022223566881 25138147452 999958020 diff --git a/examples/testsets/abc129-f/in/sub1_small_01.txt b/examples/testsets/abc129-f/in/sub1_small_01.txt new file mode 100644 index 0000000..4cddd91 --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_small_01.txt @@ -0,0 +1 @@ +18 912087068546306627 3164574410046630 996674566 diff --git a/examples/testsets/abc129-f/in/sub1_small_02.txt b/examples/testsets/abc129-f/in/sub1_small_02.txt new file mode 100644 index 0000000..00b538c --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_small_02.txt @@ -0,0 +1 @@ +31940 139378099479290043 26943708742238 1000000000 diff --git a/examples/testsets/abc129-f/in/sub1_small_03.txt b/examples/testsets/abc129-f/in/sub1_small_03.txt new file mode 100644 index 0000000..133c54d --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_small_03.txt @@ -0,0 +1 @@ +345 493299812499659259 1418510335032035 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_small_04.txt b/examples/testsets/abc129-f/in/sub1_small_04.txt new file mode 100644 index 0000000..6daed7f --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_small_04.txt @@ -0,0 +1 @@ +3776 494095262613235502 19199433662734 999999 diff --git a/examples/testsets/abc129-f/in/sub1_small_05.txt b/examples/testsets/abc129-f/in/sub1_small_05.txt new file mode 100644 index 0000000..3b1845d --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_small_05.txt @@ -0,0 +1 @@ +461491 67429808854595636 2017247872269 276712227 diff --git a/examples/testsets/abc129-f/in/sub1_small_06.txt b/examples/testsets/abc129-f/in/sub1_small_06.txt new file mode 100644 index 0000000..f52b3dd --- /dev/null +++ b/examples/testsets/abc129-f/in/sub1_small_06.txt @@ -0,0 +1 @@ +147 4222724580641548 6588820255446743 982883281 diff --git a/examples/testsets/abc129-f/out/sample_01.txt b/examples/testsets/abc129-f/out/sample_01.txt new file mode 100644 index 0000000..f3e5209 --- /dev/null +++ b/examples/testsets/abc129-f/out/sample_01.txt @@ -0,0 +1 @@ +5563 diff --git a/examples/testsets/abc129-f/out/sample_02.txt b/examples/testsets/abc129-f/out/sample_02.txt new file mode 100644 index 0000000..ebe706b --- /dev/null +++ b/examples/testsets/abc129-f/out/sample_02.txt @@ -0,0 +1 @@ +891011 diff --git a/examples/testsets/abc129-f/out/sample_03.txt b/examples/testsets/abc129-f/out/sample_03.txt new file mode 100644 index 0000000..d7e18ae --- /dev/null +++ b/examples/testsets/abc129-f/out/sample_03.txt @@ -0,0 +1 @@ +39122908 diff --git a/examples/testsets/abc129-f/out/sub1_killer_01.txt b/examples/testsets/abc129-f/out/sub1_killer_01.txt new file mode 100644 index 0000000..10b65f2 --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_killer_01.txt @@ -0,0 +1 @@ +900161126 diff --git a/examples/testsets/abc129-f/out/sub1_killer_02.txt b/examples/testsets/abc129-f/out/sub1_killer_02.txt new file mode 100644 index 0000000..a851e0c --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_killer_02.txt @@ -0,0 +1 @@ +658481246 diff --git a/examples/testsets/abc129-f/out/sub1_killer_03.txt b/examples/testsets/abc129-f/out/sub1_killer_03.txt new file mode 100644 index 0000000..43cff07 --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_killer_03.txt @@ -0,0 +1 @@ +521296277 diff --git a/examples/testsets/abc129-f/out/sub1_killer_04.txt b/examples/testsets/abc129-f/out/sub1_killer_04.txt new file mode 100644 index 0000000..1c41192 --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_killer_04.txt @@ -0,0 +1 @@ +716070897 diff --git a/examples/testsets/abc129-f/out/sub1_killer_05.txt b/examples/testsets/abc129-f/out/sub1_killer_05.txt new file mode 100644 index 0000000..f8a402d --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_killer_05.txt @@ -0,0 +1 @@ +9086340 diff --git a/examples/testsets/abc129-f/out/sub1_killer_06.txt b/examples/testsets/abc129-f/out/sub1_killer_06.txt new file mode 100644 index 0000000..2e84594 --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_killer_06.txt @@ -0,0 +1 @@ +822961451 diff --git a/examples/testsets/abc129-f/out/sub1_killer_07.txt b/examples/testsets/abc129-f/out/sub1_killer_07.txt new file mode 100644 index 0000000..56b4803 --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_killer_07.txt @@ -0,0 +1 @@ +12975 diff --git a/examples/testsets/abc129-f/out/sub1_large_01.txt b/examples/testsets/abc129-f/out/sub1_large_01.txt new file mode 100644 index 0000000..28e56d9 --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_large_01.txt @@ -0,0 +1 @@ +999999999 diff --git a/examples/testsets/abc129-f/out/sub1_large_02.txt b/examples/testsets/abc129-f/out/sub1_large_02.txt new file mode 100644 index 0000000..7a2f4fe --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_large_02.txt @@ -0,0 +1 @@ +739823859 diff --git a/examples/testsets/abc129-f/out/sub1_large_03.txt b/examples/testsets/abc129-f/out/sub1_large_03.txt new file mode 100644 index 0000000..6f3846a --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_large_03.txt @@ -0,0 +1 @@ +7215183 diff --git a/examples/testsets/abc129-f/out/sub1_large_04.txt b/examples/testsets/abc129-f/out/sub1_large_04.txt new file mode 100644 index 0000000..7d3d74f --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_large_04.txt @@ -0,0 +1 @@ +795127085 diff --git a/examples/testsets/abc129-f/out/sub1_large_05.txt b/examples/testsets/abc129-f/out/sub1_large_05.txt new file mode 100644 index 0000000..ad676a4 --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_large_05.txt @@ -0,0 +1 @@ +222138048 diff --git a/examples/testsets/abc129-f/out/sub1_large_06.txt b/examples/testsets/abc129-f/out/sub1_large_06.txt new file mode 100644 index 0000000..a6bb95b --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_large_06.txt @@ -0,0 +1 @@ +96844045 diff --git a/examples/testsets/abc129-f/out/sub1_large_07.txt b/examples/testsets/abc129-f/out/sub1_large_07.txt new file mode 100644 index 0000000..4f87764 --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_large_07.txt @@ -0,0 +1 @@ +257000862 diff --git a/examples/testsets/abc129-f/out/sub1_large_08.txt b/examples/testsets/abc129-f/out/sub1_large_08.txt new file mode 100644 index 0000000..5c43ef6 --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_large_08.txt @@ -0,0 +1 @@ +55813670 diff --git a/examples/testsets/abc129-f/out/sub1_large_09.txt b/examples/testsets/abc129-f/out/sub1_large_09.txt new file mode 100644 index 0000000..a714ffb --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_large_09.txt @@ -0,0 +1 @@ +109152748 diff --git a/examples/testsets/abc129-f/out/sub1_rand_01.txt b/examples/testsets/abc129-f/out/sub1_rand_01.txt new file mode 100644 index 0000000..47237fc --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_rand_01.txt @@ -0,0 +1 @@ +932512687 diff --git a/examples/testsets/abc129-f/out/sub1_rand_02.txt b/examples/testsets/abc129-f/out/sub1_rand_02.txt new file mode 100644 index 0000000..3569ef6 --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_rand_02.txt @@ -0,0 +1 @@ +976788549 diff --git a/examples/testsets/abc129-f/out/sub1_rand_03.txt b/examples/testsets/abc129-f/out/sub1_rand_03.txt new file mode 100644 index 0000000..446994c --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_rand_03.txt @@ -0,0 +1 @@ +84300371 diff --git a/examples/testsets/abc129-f/out/sub1_rand_04.txt b/examples/testsets/abc129-f/out/sub1_rand_04.txt new file mode 100644 index 0000000..930a068 --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_rand_04.txt @@ -0,0 +1 @@ +336830166 diff --git a/examples/testsets/abc129-f/out/sub1_rand_05.txt b/examples/testsets/abc129-f/out/sub1_rand_05.txt new file mode 100644 index 0000000..f98cf2c --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_rand_05.txt @@ -0,0 +1 @@ +699837 diff --git a/examples/testsets/abc129-f/out/sub1_rand_06.txt b/examples/testsets/abc129-f/out/sub1_rand_06.txt new file mode 100644 index 0000000..123565f --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_rand_06.txt @@ -0,0 +1 @@ +184277614 diff --git a/examples/testsets/abc129-f/out/sub1_rand_07.txt b/examples/testsets/abc129-f/out/sub1_rand_07.txt new file mode 100644 index 0000000..7fe4b6d --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_rand_07.txt @@ -0,0 +1 @@ +357790932 diff --git a/examples/testsets/abc129-f/out/sub1_rand_08.txt b/examples/testsets/abc129-f/out/sub1_rand_08.txt new file mode 100644 index 0000000..7f65140 --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_rand_08.txt @@ -0,0 +1 @@ +878717921 diff --git a/examples/testsets/abc129-f/out/sub1_rand_09.txt b/examples/testsets/abc129-f/out/sub1_rand_09.txt new file mode 100644 index 0000000..38ba959 --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_rand_09.txt @@ -0,0 +1 @@ +207193062 diff --git a/examples/testsets/abc129-f/out/sub1_rand_10.txt b/examples/testsets/abc129-f/out/sub1_rand_10.txt new file mode 100644 index 0000000..8773a4d --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_rand_10.txt @@ -0,0 +1 @@ +336284961 diff --git a/examples/testsets/abc129-f/out/sub1_small_01.txt b/examples/testsets/abc129-f/out/sub1_small_01.txt new file mode 100644 index 0000000..9906162 --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_small_01.txt @@ -0,0 +1 @@ +564963471 diff --git a/examples/testsets/abc129-f/out/sub1_small_02.txt b/examples/testsets/abc129-f/out/sub1_small_02.txt new file mode 100644 index 0000000..8242c5e --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_small_02.txt @@ -0,0 +1 @@ +997629525 diff --git a/examples/testsets/abc129-f/out/sub1_small_03.txt b/examples/testsets/abc129-f/out/sub1_small_03.txt new file mode 100644 index 0000000..d0ba21a --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_small_03.txt @@ -0,0 +1 @@ +390889114 diff --git a/examples/testsets/abc129-f/out/sub1_small_04.txt b/examples/testsets/abc129-f/out/sub1_small_04.txt new file mode 100644 index 0000000..36aaed9 --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_small_04.txt @@ -0,0 +1 @@ +792884 diff --git a/examples/testsets/abc129-f/out/sub1_small_05.txt b/examples/testsets/abc129-f/out/sub1_small_05.txt new file mode 100644 index 0000000..93f44a4 --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_small_05.txt @@ -0,0 +1 @@ +203043563 diff --git a/examples/testsets/abc129-f/out/sub1_small_06.txt b/examples/testsets/abc129-f/out/sub1_small_06.txt new file mode 100644 index 0000000..f472c41 --- /dev/null +++ b/examples/testsets/abc129-f/out/sub1_small_06.txt @@ -0,0 +1 @@ +887967106 From 5b356b2a3c2711c49a19a096dbf1a28f3d72b773 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Thu, 19 Dec 2019 20:40:01 +0900 Subject: [PATCH 02/39] Add a test for ABC077/ARC084-C --- examples/arc084-c.rs | 48 +++++++++++++++++++++++++++ examples/tests.ron | 4 +++ examples/testsets/arc084-c/in/s1.txt | 4 +++ examples/testsets/arc084-c/in/s2.txt | 4 +++ examples/testsets/arc084-c/in/s3.txt | 4 +++ examples/testsets/arc084-c/out/s1.txt | 1 + examples/testsets/arc084-c/out/s2.txt | 1 + examples/testsets/arc084-c/out/s3.txt | 1 + 8 files changed, 67 insertions(+) create mode 100644 examples/arc084-c.rs create mode 100644 examples/testsets/arc084-c/in/s1.txt create mode 100644 examples/testsets/arc084-c/in/s2.txt create mode 100644 examples/testsets/arc084-c/in/s3.txt create mode 100644 examples/testsets/arc084-c/out/s1.txt create mode 100644 examples/testsets/arc084-c/out/s2.txt create mode 100644 examples/testsets/arc084-c/out/s3.txt diff --git a/examples/arc084-c.rs b/examples/arc084-c.rs new file mode 100644 index 0000000..dee0b17 --- /dev/null +++ b/examples/arc084-c.rs @@ -0,0 +1,48 @@ +// https://atcoder.jp/contests/arc084/tasks/arc084_a + +use superslice::Ext as _; + +fn main() { + // use std::io::{self, Read as _}; + // + // let mut input = "".to_owned(); + // io::stdin().read_to_string(&mut input).unwrap(); + // let mut input = input.split_whitespace(); + // macro_rules! read { + // ([$t:tt; $n:expr]) => { + // (0..$n).map(|_| read!($t)).collect::>() + // }; + // (($($t:tt),+)) => { + // ($(read!($t)),*) + // }; + // (_1based) => { + // read!(usize) - 1 + // }; + // (_bytes) => { + // read!(String).into_bytes() + // }; + // ($ty:ty) => { + // input.next().unwrap().parse::<$ty>().unwrap() + // }; + // } + // + // let n = read!(n); + // let (mut a, b, mut c) = read!(([u32; n], [u32; n], [u32; n])); + + use proconio::input; + + input! { + n: usize, + mut a: [u32; n], + b: [u32; n], + mut c: [u32; n], + } + + a.sort(); + c.sort(); + let ans = b + .into_iter() + .map(|b| a.lower_bound(&b) * (n - c.upper_bound(&b))) + .sum::(); + println!("{}", ans); +} diff --git a/examples/tests.ron b/examples/tests.ron index 49b4f7a..fac6f38 100644 --- a/examples/tests.ron +++ b/examples/tests.ron @@ -35,6 +35,10 @@ name: "ABC045: C - One-stroke Path", matching: ExactWords, ), + "arc084-c": ( + name: "ABC077 / ARC084: C - Snuke Festival", + matching: ExactWords, + ), "abc084-d": ( name: "ABC084: D - 2017-like Number", matching: ExactWords, diff --git a/examples/testsets/arc084-c/in/s1.txt b/examples/testsets/arc084-c/in/s1.txt new file mode 100644 index 0000000..094d702 --- /dev/null +++ b/examples/testsets/arc084-c/in/s1.txt @@ -0,0 +1,4 @@ +2 +1 5 +2 4 +3 6 diff --git a/examples/testsets/arc084-c/in/s2.txt b/examples/testsets/arc084-c/in/s2.txt new file mode 100644 index 0000000..a304b91 --- /dev/null +++ b/examples/testsets/arc084-c/in/s2.txt @@ -0,0 +1,4 @@ +3 +1 1 1 +2 2 2 +3 3 3 diff --git a/examples/testsets/arc084-c/in/s3.txt b/examples/testsets/arc084-c/in/s3.txt new file mode 100644 index 0000000..ad6543d --- /dev/null +++ b/examples/testsets/arc084-c/in/s3.txt @@ -0,0 +1,4 @@ +6 +3 14 159 2 6 53 +58 9 79 323 84 6 +2643 383 2 79 50 288 diff --git a/examples/testsets/arc084-c/out/s1.txt b/examples/testsets/arc084-c/out/s1.txt new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/examples/testsets/arc084-c/out/s1.txt @@ -0,0 +1 @@ +3 diff --git a/examples/testsets/arc084-c/out/s2.txt b/examples/testsets/arc084-c/out/s2.txt new file mode 100644 index 0000000..f64f5d8 --- /dev/null +++ b/examples/testsets/arc084-c/out/s2.txt @@ -0,0 +1 @@ +27 diff --git a/examples/testsets/arc084-c/out/s3.txt b/examples/testsets/arc084-c/out/s3.txt new file mode 100644 index 0000000..84df352 --- /dev/null +++ b/examples/testsets/arc084-c/out/s3.txt @@ -0,0 +1 @@ +87 From 2beb8ac5723018dad4a4e2774753ffb21f8ec562 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Fri, 20 Dec 2019 12:19:34 +0900 Subject: [PATCH 03/39] Add a test for ABC144-D --- examples/abc144-d.rs | 23 ++++++++++++ examples/tests.ron | 36 ++++++++++--------- examples/testsets/abc144-d/in/handmade03.txt | 1 + examples/testsets/abc144-d/in/handmade04.txt | 1 + examples/testsets/abc144-d/in/random05.txt | 1 + examples/testsets/abc144-d/in/random06.txt | 1 + examples/testsets/abc144-d/in/random07.txt | 1 + examples/testsets/abc144-d/in/random08.txt | 1 + examples/testsets/abc144-d/in/random09.txt | 1 + examples/testsets/abc144-d/in/random10.txt | 1 + examples/testsets/abc144-d/in/random11.txt | 1 + examples/testsets/abc144-d/in/random12.txt | 1 + examples/testsets/abc144-d/in/random13.txt | 1 + examples/testsets/abc144-d/in/random14.txt | 1 + examples/testsets/abc144-d/in/sample00.txt | 1 + examples/testsets/abc144-d/in/sample01.txt | 1 + examples/testsets/abc144-d/in/sample02.txt | 1 + examples/testsets/abc144-d/out/handmade03.txt | 1 + examples/testsets/abc144-d/out/handmade04.txt | 1 + examples/testsets/abc144-d/out/random05.txt | 1 + examples/testsets/abc144-d/out/random06.txt | 1 + examples/testsets/abc144-d/out/random07.txt | 1 + examples/testsets/abc144-d/out/random08.txt | 1 + examples/testsets/abc144-d/out/random09.txt | 1 + examples/testsets/abc144-d/out/random10.txt | 1 + examples/testsets/abc144-d/out/random11.txt | 1 + examples/testsets/abc144-d/out/random12.txt | 1 + examples/testsets/abc144-d/out/random13.txt | 1 + examples/testsets/abc144-d/out/random14.txt | 1 + examples/testsets/abc144-d/out/sample00.txt | 1 + examples/testsets/abc144-d/out/sample01.txt | 1 + examples/testsets/abc144-d/out/sample02.txt | 1 + tools/test-with-generated-opts/Cargo.toml | 5 +-- tools/test-with-generated-opts/src/main.rs | 35 +++++++++++++++--- 34 files changed, 107 insertions(+), 22 deletions(-) create mode 100644 examples/abc144-d.rs create mode 100644 examples/testsets/abc144-d/in/handmade03.txt create mode 100644 examples/testsets/abc144-d/in/handmade04.txt create mode 100644 examples/testsets/abc144-d/in/random05.txt create mode 100644 examples/testsets/abc144-d/in/random06.txt create mode 100644 examples/testsets/abc144-d/in/random07.txt create mode 100644 examples/testsets/abc144-d/in/random08.txt create mode 100644 examples/testsets/abc144-d/in/random09.txt create mode 100644 examples/testsets/abc144-d/in/random10.txt create mode 100644 examples/testsets/abc144-d/in/random11.txt create mode 100644 examples/testsets/abc144-d/in/random12.txt create mode 100644 examples/testsets/abc144-d/in/random13.txt create mode 100644 examples/testsets/abc144-d/in/random14.txt create mode 100644 examples/testsets/abc144-d/in/sample00.txt create mode 100644 examples/testsets/abc144-d/in/sample01.txt create mode 100644 examples/testsets/abc144-d/in/sample02.txt create mode 100644 examples/testsets/abc144-d/out/handmade03.txt create mode 100644 examples/testsets/abc144-d/out/handmade04.txt create mode 100644 examples/testsets/abc144-d/out/random05.txt create mode 100644 examples/testsets/abc144-d/out/random06.txt create mode 100644 examples/testsets/abc144-d/out/random07.txt create mode 100644 examples/testsets/abc144-d/out/random08.txt create mode 100644 examples/testsets/abc144-d/out/random09.txt create mode 100644 examples/testsets/abc144-d/out/random10.txt create mode 100644 examples/testsets/abc144-d/out/random11.txt create mode 100644 examples/testsets/abc144-d/out/random12.txt create mode 100644 examples/testsets/abc144-d/out/random13.txt create mode 100644 examples/testsets/abc144-d/out/random14.txt create mode 100644 examples/testsets/abc144-d/out/sample00.txt create mode 100644 examples/testsets/abc144-d/out/sample01.txt create mode 100644 examples/testsets/abc144-d/out/sample02.txt diff --git a/examples/abc144-d.rs b/examples/abc144-d.rs new file mode 100644 index 0000000..699fdb4 --- /dev/null +++ b/examples/abc144-d.rs @@ -0,0 +1,23 @@ +// https://atcoder.jp/contests/abc144/tasks/abc144_d + +use defmac::defmac; + +use std::f64::consts::PI; +use std::io::{self, Read as _}; + +fn main() { + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + defmac!(read => input.next().unwrap().parse().unwrap()); + + let (a, b, x): (f64, f64, f64) = (read!(), read!(), read!()); + + let ans = 180.0 / PI + * if x >= (a.powi(2) * b) / 2.0 { + libm::atan2(2.0 * (a.powi(2) * b - x), a.powi(3)) + } else { + PI / 2.0 - libm::atan2(2.0 * x, a * b.powi(2)) + }; + println!("{}", ans); +} diff --git a/examples/tests.ron b/examples/tests.ron index fac6f38..e0a7454 100644 --- a/examples/tests.ron +++ b/examples/tests.ron @@ -1,59 +1,63 @@ -// 手元でDropboxのテストケース(ある場合)で確認し、Gitに含めるのはそのうちサンプルのみ。 -// CI上でもサンプルだけテストする。(Dropboxから引っ張るのも面倒だし何より誰のアカウントを使うかという問題がある) +// 手元でDropboxのテストケース(ある場合)で確認し、サンプルに含まれていないやつが大きいときはそれらをGitに入れない。 +// その場合CI上でもサンプルだけテストする。(Dropboxから引っ張るのも面倒だし何より誰のアカウントを使うかという問題がある) ( tests: { "apg4b-a": ( name: "APG4b: A - 1.00.はじめに", - matching: ExactWhole, + matching: Exact, ), "apg4b-ex25": ( name: "APG4b: EX25 - 集合の操作 / 3.05", - matching: ExactWords, + matching: Words, ), "apg4b-ex26": ( name: "APG4b: EX26 - 電卓を作ろう3 / 3.06", - matching: ExactWords, + matching: Exact, ), "practice-a": ( name: "practice contest: A - Welcome to AtCoder", - matching: ExactWords, + matching: Words, ), "atc001-b": ( name: "ATC001: B - Union Find", - matching: ExactWords, + matching: Words, ), "atc002-b": ( name: "ATC002: B - n^p mod m", - matching: ExactWords, + matching: Words, ), "arc065-c": ( name: "ABC049 / ARC065: C - 白昼夢 / Daydream", - matching: ExactWords, + matching: Words, ), "abc054-c": ( name: "ABC045: C - One-stroke Path", - matching: ExactWords, + matching: Words, ), "arc084-c": ( name: "ABC077 / ARC084: C - Snuke Festival", - matching: ExactWords, + matching: Words, ), "abc084-d": ( name: "ABC084: D - 2017-like Number", - matching: ExactWords, + matching: Words, ), "abc120-d": ( name: "ABC120: D - Decayed Bridges", - matching: ExactWords, + matching: Words, ), "abc129-f": ( name: "ABC129: F - Takahashi's Basics in Education and Learning", - matching: ExactWords, + matching: Words, ), "abc142-d": ( - name: "ABC124: D - Disjoint Set of Common Divisors", - matching: ExactWords, + name: "ABC142: D - Disjoint Set of Common Divisors", + matching: Words, + ), + "abc144-d": ( + name: "ABC144: D - Water Bottle", + matching: FloatOr(abs: 1e-6, rel: 1e-6), ), } ) diff --git a/examples/testsets/abc144-d/in/handmade03.txt b/examples/testsets/abc144-d/in/handmade03.txt new file mode 100644 index 0000000..8e93976 --- /dev/null +++ b/examples/testsets/abc144-d/in/handmade03.txt @@ -0,0 +1 @@ +100 100 1000000 diff --git a/examples/testsets/abc144-d/in/handmade04.txt b/examples/testsets/abc144-d/in/handmade04.txt new file mode 100644 index 0000000..7fbeff6 --- /dev/null +++ b/examples/testsets/abc144-d/in/handmade04.txt @@ -0,0 +1 @@ +100 100 1 diff --git a/examples/testsets/abc144-d/in/random05.txt b/examples/testsets/abc144-d/in/random05.txt new file mode 100644 index 0000000..14990bf --- /dev/null +++ b/examples/testsets/abc144-d/in/random05.txt @@ -0,0 +1 @@ +22 75 24126 diff --git a/examples/testsets/abc144-d/in/random06.txt b/examples/testsets/abc144-d/in/random06.txt new file mode 100644 index 0000000..755b7bf --- /dev/null +++ b/examples/testsets/abc144-d/in/random06.txt @@ -0,0 +1 @@ +45 72 83481 diff --git a/examples/testsets/abc144-d/in/random07.txt b/examples/testsets/abc144-d/in/random07.txt new file mode 100644 index 0000000..39779cd --- /dev/null +++ b/examples/testsets/abc144-d/in/random07.txt @@ -0,0 +1 @@ +47 29 44734 diff --git a/examples/testsets/abc144-d/in/random08.txt b/examples/testsets/abc144-d/in/random08.txt new file mode 100644 index 0000000..3879741 --- /dev/null +++ b/examples/testsets/abc144-d/in/random08.txt @@ -0,0 +1 @@ +2 75 25 diff --git a/examples/testsets/abc144-d/in/random09.txt b/examples/testsets/abc144-d/in/random09.txt new file mode 100644 index 0000000..743d648 --- /dev/null +++ b/examples/testsets/abc144-d/in/random09.txt @@ -0,0 +1 @@ +82 84 416241 diff --git a/examples/testsets/abc144-d/in/random10.txt b/examples/testsets/abc144-d/in/random10.txt new file mode 100644 index 0000000..f6ed7a2 --- /dev/null +++ b/examples/testsets/abc144-d/in/random10.txt @@ -0,0 +1 @@ +56 32 30430 diff --git a/examples/testsets/abc144-d/in/random11.txt b/examples/testsets/abc144-d/in/random11.txt new file mode 100644 index 0000000..a7f6400 --- /dev/null +++ b/examples/testsets/abc144-d/in/random11.txt @@ -0,0 +1 @@ +28 37 11105 diff --git a/examples/testsets/abc144-d/in/random12.txt b/examples/testsets/abc144-d/in/random12.txt new file mode 100644 index 0000000..335f3df --- /dev/null +++ b/examples/testsets/abc144-d/in/random12.txt @@ -0,0 +1 @@ +39 18 23359 diff --git a/examples/testsets/abc144-d/in/random13.txt b/examples/testsets/abc144-d/in/random13.txt new file mode 100644 index 0000000..198104c --- /dev/null +++ b/examples/testsets/abc144-d/in/random13.txt @@ -0,0 +1 @@ +79 6 29018 diff --git a/examples/testsets/abc144-d/in/random14.txt b/examples/testsets/abc144-d/in/random14.txt new file mode 100644 index 0000000..69c13fe --- /dev/null +++ b/examples/testsets/abc144-d/in/random14.txt @@ -0,0 +1 @@ +68 68 313904 diff --git a/examples/testsets/abc144-d/in/sample00.txt b/examples/testsets/abc144-d/in/sample00.txt new file mode 100644 index 0000000..f50aaec --- /dev/null +++ b/examples/testsets/abc144-d/in/sample00.txt @@ -0,0 +1 @@ +2 2 4 diff --git a/examples/testsets/abc144-d/in/sample01.txt b/examples/testsets/abc144-d/in/sample01.txt new file mode 100644 index 0000000..4fe9466 --- /dev/null +++ b/examples/testsets/abc144-d/in/sample01.txt @@ -0,0 +1 @@ +12 21 10 diff --git a/examples/testsets/abc144-d/in/sample02.txt b/examples/testsets/abc144-d/in/sample02.txt new file mode 100644 index 0000000..469cc0f --- /dev/null +++ b/examples/testsets/abc144-d/in/sample02.txt @@ -0,0 +1 @@ +3 1 8 diff --git a/examples/testsets/abc144-d/out/handmade03.txt b/examples/testsets/abc144-d/out/handmade03.txt new file mode 100644 index 0000000..c9ea018 --- /dev/null +++ b/examples/testsets/abc144-d/out/handmade03.txt @@ -0,0 +1 @@ +0.0000000000 diff --git a/examples/testsets/abc144-d/out/handmade04.txt b/examples/testsets/abc144-d/out/handmade04.txt new file mode 100644 index 0000000..04e6032 --- /dev/null +++ b/examples/testsets/abc144-d/out/handmade04.txt @@ -0,0 +1 @@ +89.9998854084 diff --git a/examples/testsets/abc144-d/out/random05.txt b/examples/testsets/abc144-d/out/random05.txt new file mode 100644 index 0000000..360fb06 --- /dev/null +++ b/examples/testsets/abc144-d/out/random05.txt @@ -0,0 +1 @@ +66.3790171829 diff --git a/examples/testsets/abc144-d/out/random06.txt b/examples/testsets/abc144-d/out/random06.txt new file mode 100644 index 0000000..4520afe --- /dev/null +++ b/examples/testsets/abc144-d/out/random06.txt @@ -0,0 +1 @@ +53.8288157430 diff --git a/examples/testsets/abc144-d/out/random07.txt b/examples/testsets/abc144-d/out/random07.txt new file mode 100644 index 0000000..d696f30 --- /dev/null +++ b/examples/testsets/abc144-d/out/random07.txt @@ -0,0 +1 @@ +20.4206366709 diff --git a/examples/testsets/abc144-d/out/random08.txt b/examples/testsets/abc144-d/out/random08.txt new file mode 100644 index 0000000..695b836 --- /dev/null +++ b/examples/testsets/abc144-d/out/random08.txt @@ -0,0 +1 @@ +89.7453537677 diff --git a/examples/testsets/abc144-d/out/random09.txt b/examples/testsets/abc144-d/out/random09.txt new file mode 100644 index 0000000..675a819 --- /dev/null +++ b/examples/testsets/abc144-d/out/random09.txt @@ -0,0 +1 @@ +28.3216596827 diff --git a/examples/testsets/abc144-d/out/random10.txt b/examples/testsets/abc144-d/out/random10.txt new file mode 100644 index 0000000..dad6b80 --- /dev/null +++ b/examples/testsets/abc144-d/out/random10.txt @@ -0,0 +1 @@ +43.2962287317 diff --git a/examples/testsets/abc144-d/out/random11.txt b/examples/testsets/abc144-d/out/random11.txt new file mode 100644 index 0000000..5aade64 --- /dev/null +++ b/examples/testsets/abc144-d/out/random11.txt @@ -0,0 +1 @@ +59.9115059975 diff --git a/examples/testsets/abc144-d/out/random12.txt b/examples/testsets/abc144-d/out/random12.txt new file mode 100644 index 0000000..7d70f65 --- /dev/null +++ b/examples/testsets/abc144-d/out/random12.txt @@ -0,0 +1 @@ +7.7168423353 diff --git a/examples/testsets/abc144-d/out/random13.txt b/examples/testsets/abc144-d/out/random13.txt new file mode 100644 index 0000000..91cc451 --- /dev/null +++ b/examples/testsets/abc144-d/out/random13.txt @@ -0,0 +1 @@ +1.9580634609 diff --git a/examples/testsets/abc144-d/out/random14.txt b/examples/testsets/abc144-d/out/random14.txt new file mode 100644 index 0000000..6b0d01f --- /dev/null +++ b/examples/testsets/abc144-d/out/random14.txt @@ -0,0 +1 @@ +0.1924235310 diff --git a/examples/testsets/abc144-d/out/sample00.txt b/examples/testsets/abc144-d/out/sample00.txt new file mode 100644 index 0000000..5d86419 --- /dev/null +++ b/examples/testsets/abc144-d/out/sample00.txt @@ -0,0 +1 @@ +45.0000000000 diff --git a/examples/testsets/abc144-d/out/sample01.txt b/examples/testsets/abc144-d/out/sample01.txt new file mode 100644 index 0000000..09c2e94 --- /dev/null +++ b/examples/testsets/abc144-d/out/sample01.txt @@ -0,0 +1 @@ +89.7834636934 diff --git a/examples/testsets/abc144-d/out/sample02.txt b/examples/testsets/abc144-d/out/sample02.txt new file mode 100644 index 0000000..d3b8514 --- /dev/null +++ b/examples/testsets/abc144-d/out/sample02.txt @@ -0,0 +1 @@ +4.2363947991 diff --git a/tools/test-with-generated-opts/Cargo.toml b/tools/test-with-generated-opts/Cargo.toml index 005577f..abd5a7a 100644 --- a/tools/test-with-generated-opts/Cargo.toml +++ b/tools/test-with-generated-opts/Cargo.toml @@ -7,13 +7,14 @@ description = "Test with `rustc-dep-option-generator`." [dependencies] anyhow = "1.0.25" +approx = "0.3.2" env_logger = "0.7.1" indexmap = { version = "1.3.0", features = ["serde-1"] } itertools = "0.8.2" log = "0.4.8" ron = "0.5.1" -serde = { version = "1.0.103", features = ["derive"] } -serde_json = "1.0.42" +serde = { version = "1.0.104", features = ["derive"] } +serde_json = "1.0.44" shell-escape = "0.1.4" structopt = "0.3.5" tempdir = "0.3.7" diff --git a/tools/test-with-generated-opts/src/main.rs b/tools/test-with-generated-opts/src/main.rs index f78d031..e7dfa85 100644 --- a/tools/test-with-generated-opts/src/main.rs +++ b/tools/test-with-generated-opts/src/main.rs @@ -1,4 +1,5 @@ use anyhow::{anyhow, Context as _}; +use approx::{abs_diff_eq, relative_eq}; use env_logger::fmt::Color; use indexmap::IndexMap; use itertools::Itertools as _; @@ -9,6 +10,7 @@ use tempdir::TempDir; use std::collections::{BTreeMap, HashMap}; use std::env; +use std::f64; use std::ffi::{OsStr, OsString}; use std::fs::{self, File}; use std::io::{self, Read as _, Write as _}; @@ -222,17 +224,42 @@ struct Test { #[derive(Debug, Clone, Copy, Deserialize)] enum Matching { - ExactWhole, - ExactWords, + Exact, + Words, + FloatOr { + #[serde(default = "nan")] + abs: f64, + #[serde(default = "nan")] + rel: f64, + }, +} + +const fn nan() -> f64 { + f64::NAN } impl Matching { fn accepts(self, expected: &str, actual: &str) -> bool { match self { - Matching::ExactWhole => expected == actual, - Matching::ExactWords => { + Matching::Exact => expected == actual, + Matching::Words => { itertools::equal(expected.split_whitespace(), actual.split_whitespace()) } + Matching::FloatOr { abs, rel } => itertools::diff_with( + expected.split_whitespace(), + actual.split_whitespace(), + |expected, actual| { + if let (Ok(expected), Ok(actual)) = + (expected.parse::(), actual.parse::()) + { + abs_diff_eq!(expected, actual, epsilon = abs) + || relative_eq!(expected, actual, max_relative = rel) + } else { + expected == actual + } + }, + ) + .is_none(), } } } From 1aa9c37b4f31989e47b96cfe7ae74002f91ae667 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Fri, 20 Dec 2019 17:15:55 +0900 Subject: [PATCH 04/39] Add a test for ABC057-B --- examples/abc057-b.rs | 26 ++++++++++++++++++++ examples/tests.ron | 6 ++++- examples/testsets/abc057-b/in/sample_01.txt | 5 ++++ examples/testsets/abc057-b/in/sample_02.txt | 8 ++++++ examples/testsets/abc057-b/in/sample_03.txt | 11 +++++++++ examples/testsets/abc057-b/out/sample_01.txt | 2 ++ examples/testsets/abc057-b/out/sample_02.txt | 3 +++ examples/testsets/abc057-b/out/sample_03.txt | 5 ++++ 8 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 examples/abc057-b.rs create mode 100644 examples/testsets/abc057-b/in/sample_01.txt create mode 100644 examples/testsets/abc057-b/in/sample_02.txt create mode 100644 examples/testsets/abc057-b/in/sample_03.txt create mode 100644 examples/testsets/abc057-b/out/sample_01.txt create mode 100644 examples/testsets/abc057-b/out/sample_02.txt create mode 100644 examples/testsets/abc057-b/out/sample_03.txt diff --git a/examples/abc057-b.rs b/examples/abc057-b.rs new file mode 100644 index 0000000..2f22337 --- /dev/null +++ b/examples/abc057-b.rs @@ -0,0 +1,26 @@ +// https://atcoder.jp/contests/abc057/tasks/abc057_b + +#![allow(clippy::many_single_char_names, clippy::try_err)] + +use text_io::{read, try_read, try_scan}; + +fn main() { + let n: usize = read!(); + let m: usize = read!(); + let abs = (0..n) + .map(|_| (read!(), read!())) + .collect::>(); + let cds = (0..m) + .map(|_| (read!(), read!())) + .collect::>(); + + for (a, b) in abs { + let j = (0..m) + .min_by_key(|&j| { + let (c, d) = cds[j]; + (a - c).abs() + (b - d).abs() + }) + .unwrap(); + println!("{}", j + 1); + } +} diff --git a/examples/tests.ron b/examples/tests.ron index e0a7454..25604da 100644 --- a/examples/tests.ron +++ b/examples/tests.ron @@ -32,7 +32,11 @@ matching: Words, ), "abc054-c": ( - name: "ABC045: C - One-stroke Path", + name: "ABC054: C - One-stroke Path", + matching: Words, + ), + "abc057-b": ( + name: "ABC057: B - Checkpoints", matching: Words, ), "arc084-c": ( diff --git a/examples/testsets/abc057-b/in/sample_01.txt b/examples/testsets/abc057-b/in/sample_01.txt new file mode 100644 index 0000000..c43659a --- /dev/null +++ b/examples/testsets/abc057-b/in/sample_01.txt @@ -0,0 +1,5 @@ +2 2 +2 0 +0 0 +-1 0 +1 0 diff --git a/examples/testsets/abc057-b/in/sample_02.txt b/examples/testsets/abc057-b/in/sample_02.txt new file mode 100644 index 0000000..541f6dd --- /dev/null +++ b/examples/testsets/abc057-b/in/sample_02.txt @@ -0,0 +1,8 @@ +3 4 +10 10 +-10 -10 +3 3 +1 2 +2 3 +3 5 +3 5 diff --git a/examples/testsets/abc057-b/in/sample_03.txt b/examples/testsets/abc057-b/in/sample_03.txt new file mode 100644 index 0000000..596121c --- /dev/null +++ b/examples/testsets/abc057-b/in/sample_03.txt @@ -0,0 +1,11 @@ +5 5 +-100000000 -100000000 +-100000000 100000000 +100000000 -100000000 +100000000 100000000 +0 0 +0 0 +100000000 100000000 +100000000 -100000000 +-100000000 100000000 +-100000000 -100000000 diff --git a/examples/testsets/abc057-b/out/sample_01.txt b/examples/testsets/abc057-b/out/sample_01.txt new file mode 100644 index 0000000..5f1d0ec --- /dev/null +++ b/examples/testsets/abc057-b/out/sample_01.txt @@ -0,0 +1,2 @@ +2 +1 diff --git a/examples/testsets/abc057-b/out/sample_02.txt b/examples/testsets/abc057-b/out/sample_02.txt new file mode 100644 index 0000000..0571a2e --- /dev/null +++ b/examples/testsets/abc057-b/out/sample_02.txt @@ -0,0 +1,3 @@ +3 +1 +2 diff --git a/examples/testsets/abc057-b/out/sample_03.txt b/examples/testsets/abc057-b/out/sample_03.txt new file mode 100644 index 0000000..86e24d1 --- /dev/null +++ b/examples/testsets/abc057-b/out/sample_03.txt @@ -0,0 +1,5 @@ +5 +4 +3 +2 +1 From 3d78a595220237331eb4b37ade7f306ea1c3be32 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Fri, 20 Dec 2019 17:38:57 +0900 Subject: [PATCH 05/39] Add a test for ABC118-B --- examples/abc118-b.rs | 23 ++++++++++++++++++++ examples/tests.ron | 4 ++++ examples/testsets/abc118-b/in/sample_01.txt | 4 ++++ examples/testsets/abc118-b/in/sample_02.txt | 6 +++++ examples/testsets/abc118-b/in/sample_03.txt | 2 ++ examples/testsets/abc118-b/out/sample_01.txt | 1 + examples/testsets/abc118-b/out/sample_02.txt | 1 + examples/testsets/abc118-b/out/sample_03.txt | 1 + 8 files changed, 42 insertions(+) create mode 100644 examples/abc118-b.rs create mode 100644 examples/testsets/abc118-b/in/sample_01.txt create mode 100644 examples/testsets/abc118-b/in/sample_02.txt create mode 100644 examples/testsets/abc118-b/in/sample_03.txt create mode 100644 examples/testsets/abc118-b/out/sample_01.txt create mode 100644 examples/testsets/abc118-b/out/sample_02.txt create mode 100644 examples/testsets/abc118-b/out/sample_03.txt diff --git a/examples/abc118-b.rs b/examples/abc118-b.rs new file mode 100644 index 0000000..f784580 --- /dev/null +++ b/examples/abc118-b.rs @@ -0,0 +1,23 @@ +// https://atcoder.jp/contests/abc118/tasks/abc118_b + +use whiteread::Reader; + +use std::ops::{BitAnd, BitOr}; + +fn main() { + let mut rdr = Reader::from_stdin_naive(); + let (n, _) = rdr.p::<(usize, usize)>(); + let a = (0..n) + .map(|_| { + let k = rdr.p::(); + (0..k).map(|_| rdr.p::() - 1).collect() + }) + .collect::>>(); + + let ans = a + .into_iter() + .map(|row| row.into_iter().map(|k| 1 << k).fold(0, BitOr::bitor)) + .fold(usize::max_value(), BitAnd::bitand) + .count_ones(); + println!("{}", ans); +} diff --git a/examples/tests.ron b/examples/tests.ron index 25604da..73aaedc 100644 --- a/examples/tests.ron +++ b/examples/tests.ron @@ -47,6 +47,10 @@ name: "ABC084: D - 2017-like Number", matching: Words, ), + "abc118-b": ( + name: "ABC118: B - Foods Loved by Everyone", + matching: Words, + ), "abc120-d": ( name: "ABC120: D - Decayed Bridges", matching: Words, diff --git a/examples/testsets/abc118-b/in/sample_01.txt b/examples/testsets/abc118-b/in/sample_01.txt new file mode 100644 index 0000000..b6505e4 --- /dev/null +++ b/examples/testsets/abc118-b/in/sample_01.txt @@ -0,0 +1,4 @@ +3 4 +2 1 3 +3 1 2 3 +2 3 2 diff --git a/examples/testsets/abc118-b/in/sample_02.txt b/examples/testsets/abc118-b/in/sample_02.txt new file mode 100644 index 0000000..993996b --- /dev/null +++ b/examples/testsets/abc118-b/in/sample_02.txt @@ -0,0 +1,6 @@ +5 5 +4 2 3 4 5 +4 1 3 4 5 +4 1 2 4 5 +4 1 2 3 5 +4 1 2 3 4 diff --git a/examples/testsets/abc118-b/in/sample_03.txt b/examples/testsets/abc118-b/in/sample_03.txt new file mode 100644 index 0000000..9e096c0 --- /dev/null +++ b/examples/testsets/abc118-b/in/sample_03.txt @@ -0,0 +1,2 @@ +1 30 +3 5 10 30 diff --git a/examples/testsets/abc118-b/out/sample_01.txt b/examples/testsets/abc118-b/out/sample_01.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/examples/testsets/abc118-b/out/sample_01.txt @@ -0,0 +1 @@ +1 diff --git a/examples/testsets/abc118-b/out/sample_02.txt b/examples/testsets/abc118-b/out/sample_02.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/examples/testsets/abc118-b/out/sample_02.txt @@ -0,0 +1 @@ +0 diff --git a/examples/testsets/abc118-b/out/sample_03.txt b/examples/testsets/abc118-b/out/sample_03.txt new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/examples/testsets/abc118-b/out/sample_03.txt @@ -0,0 +1 @@ +3 From 3a72838de3968377af10f6aa9dde3315ad2ffb0b Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Fri, 20 Dec 2019 17:51:33 +0900 Subject: [PATCH 06/39] Add a test for ABC121-B --- examples/abc121-b.rs | 19 +++++++++++++++++++ examples/tests.ron | 4 ++++ examples/testsets/abc121-b/in/sample_01.txt | 4 ++++ examples/testsets/abc121-b/in/sample_02.txt | 7 +++++++ examples/testsets/abc121-b/in/sample_03.txt | 5 +++++ examples/testsets/abc121-b/out/sample_01.txt | 1 + examples/testsets/abc121-b/out/sample_02.txt | 1 + examples/testsets/abc121-b/out/sample_03.txt | 1 + 8 files changed, 42 insertions(+) create mode 100644 examples/abc121-b.rs create mode 100644 examples/testsets/abc121-b/in/sample_01.txt create mode 100644 examples/testsets/abc121-b/in/sample_02.txt create mode 100644 examples/testsets/abc121-b/in/sample_03.txt create mode 100644 examples/testsets/abc121-b/out/sample_01.txt create mode 100644 examples/testsets/abc121-b/out/sample_02.txt create mode 100644 examples/testsets/abc121-b/out/sample_03.txt diff --git a/examples/abc121-b.rs b/examples/abc121-b.rs new file mode 100644 index 0000000..f4e8de7 --- /dev/null +++ b/examples/abc121-b.rs @@ -0,0 +1,19 @@ +// https://atcoder.jp/contests/abc121/tasks/abc121_b + +use proconio::input; + +fn main() { + input! { + n: usize, + m: usize, + c: i32, + b: [i32; m], + a: [[i32; m]; n], + } + + let ans = a + .into_iter() + .filter(|a| a.iter().zip(&b).map(|(a, b)| a * b).sum::() + c > 0) + .count(); + println!("{}", ans); +} diff --git a/examples/tests.ron b/examples/tests.ron index 73aaedc..ffb64b9 100644 --- a/examples/tests.ron +++ b/examples/tests.ron @@ -55,6 +55,10 @@ name: "ABC120: D - Decayed Bridges", matching: Words, ), + "abc121-b": ( + name: "ABC121: B - Can you solve this?", + matching: Words, + ), "abc129-f": ( name: "ABC129: F - Takahashi's Basics in Education and Learning", matching: Words, diff --git a/examples/testsets/abc121-b/in/sample_01.txt b/examples/testsets/abc121-b/in/sample_01.txt new file mode 100644 index 0000000..27c8ec2 --- /dev/null +++ b/examples/testsets/abc121-b/in/sample_01.txt @@ -0,0 +1,4 @@ +2 3 -10 +1 2 3 +3 2 1 +1 2 2 diff --git a/examples/testsets/abc121-b/in/sample_02.txt b/examples/testsets/abc121-b/in/sample_02.txt new file mode 100644 index 0000000..b47a11c --- /dev/null +++ b/examples/testsets/abc121-b/in/sample_02.txt @@ -0,0 +1,7 @@ +5 2 -4 +-2 5 +100 41 +100 40 +-3 0 +-6 -2 +18 -13 diff --git a/examples/testsets/abc121-b/in/sample_03.txt b/examples/testsets/abc121-b/in/sample_03.txt new file mode 100644 index 0000000..819f8c3 --- /dev/null +++ b/examples/testsets/abc121-b/in/sample_03.txt @@ -0,0 +1,5 @@ +3 3 0 +100 -100 0 +0 100 100 +100 100 100 +-100 100 100 diff --git a/examples/testsets/abc121-b/out/sample_01.txt b/examples/testsets/abc121-b/out/sample_01.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/examples/testsets/abc121-b/out/sample_01.txt @@ -0,0 +1 @@ +1 diff --git a/examples/testsets/abc121-b/out/sample_02.txt b/examples/testsets/abc121-b/out/sample_02.txt new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/examples/testsets/abc121-b/out/sample_02.txt @@ -0,0 +1 @@ +2 diff --git a/examples/testsets/abc121-b/out/sample_03.txt b/examples/testsets/abc121-b/out/sample_03.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/examples/testsets/abc121-b/out/sample_03.txt @@ -0,0 +1 @@ +0 From 4be7fead4877649713701ad7e4a473c2f645dd5b Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Fri, 20 Dec 2019 19:06:06 +0900 Subject: [PATCH 07/39] Remove `proconio::input!` from the examples other than `abc121-b` --- examples/abc054-c.rs | 68 +++++++++++++++-------------------- examples/abc084-d.rs | 64 +++++++++++++++++---------------- examples/abc120-d.rs | 82 +++++++++++++++++++++--------------------- examples/abc129-f.rs | 41 +++++---------------- examples/abc142-d.rs | 37 ++++--------------- examples/apg4b-a.rs | 2 ++ examples/apg4b-ex25.rs | 69 ++++++++++++++++------------------- examples/arc065-c.rs | 36 +++---------------- examples/arc084-c.rs | 57 +++++++++++++---------------- examples/atc001-b.rs | 67 +++++++++++++++++----------------- examples/atc002-b.rs | 28 +++++---------- examples/practice-a.rs | 28 +++++---------- 12 files changed, 231 insertions(+), 348 deletions(-) diff --git a/examples/abc054-c.rs b/examples/abc054-c.rs index 63d8f99..a1cde35 100644 --- a/examples/abc054-c.rs +++ b/examples/abc054-c.rs @@ -3,51 +3,41 @@ use petgraph::csr::Csr; use petgraph::Undirected; -fn main() { - // use std::io::{self, Read as _}; - // - // let mut input = "".to_owned(); - // io::stdin().read_to_string(&mut input).unwrap(); - // let mut input = input.split_whitespace(); - // macro_rules! read { - // ([$t:tt; $n:expr]) => { - // (0..$n).map(|_| read!($t)).collect::>() - // }; - // (($($t:tt),+)) => { - // ($(read!($t)),*) - // }; - // (_1based) => { - // read!(usize) - 1 - // }; - // (_bytes) => { - // read!(String).into_bytes() - // }; - // ($ty:ty) => { - // input.next().unwrap().parse::<$ty>().unwrap() - // }; - // } - // - // let (n, m) = read!((usize, usize)); - // let mut abs = read!([(_1based, _1based); m]); - - use proconio::input; - use proconio::marker::Usize1; +use std::io::{self, Read as _}; - input! { - n: usize, - m: usize, - mut abs: [(Usize1, Usize1); m], +fn main() { + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + macro_rules! read { + ([$tt:tt; $n:expr]) => { + (0..$n).map(|_| read!($tt)).collect::>() + }; + (($($tt:tt),+)) => { + ($(read!($tt)),*) + }; + (_1based) => { + read!(usize) - 1 + }; + (_bytes) => { + read!(String).into_bytes() + }; + ($ty:ty) => { + input.next().unwrap().parse::<$ty>().unwrap() + }; } - abs.sort(); - let mut g = Csr::<(), (), Undirected, usize>::with_nodes(n); + let (n, m) = read!((usize, usize)); + let abs = read!([(_1based, _1based); m]); + + let mut graph = Csr::<(), (), Undirected, usize>::with_nodes(n); for (a, b) in abs { - g.add_edge(a, b, ()); + graph.add_edge(a, b, ()); } let mut ans = 0; - let mut es = (0..n).collect::>(); - permutohedron::heap_recursive(&mut es, |es| { - if es[0] == 0 && es.windows(2).all(|w| g.contains_edge(w[0], w[1])) { + let mut nodes = (0..n).collect::>(); + permutohedron::heap_recursive(&mut nodes, |nodes| { + if nodes[0] == 0 && nodes.windows(2).all(|w| graph.contains_edge(w[0], w[1])) { ans += 1; } }); diff --git a/examples/abc084-d.rs b/examples/abc084-d.rs index 2a06584..3747c2b 100644 --- a/examples/abc084-d.rs +++ b/examples/abc084-d.rs @@ -3,40 +3,42 @@ use itertools_num::ItertoolsNum as _; use primal::Sieve; +use std::io::{self, Read as _}; + +// `proconio::fastout` does not accept `macro_rules!` until Rust 1.40. +macro_rules! macro_rules_hack { + ($name:ident { $($tt:tt)* }) => { + macro_rules! $name { + $($tt)* + } + }; +} + #[proconio::fastout] fn main() { - // use std::io::{self, Read as _}; - // - // let mut input = "".to_owned(); - // io::stdin().read_to_string(&mut input).unwrap(); - // let mut input = input.split_whitespace(); - // macro_rules! read { - // ([$t:tt; $n:expr]) => { - // (0..$n).map(|_| read!($t)).collect::>() - // }; - // (($($t:tt),+)) => { - // ($(read!($t)),*) - // }; - // (_1based) => { - // read!(usize) - 1 - // }; - // (_bytes) => { - // read!(String).into_bytes() - // }; - // ($ty:ty) => { - // input.next().unwrap().parse::<$ty>().unwrap() - // }; - // } - // - // let q = read!(usize); - // let lrs = read!([(usize, usize); q]); + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + macro_rules_hack!(read { + ([$tt:tt; $n:expr]) => { + (0..$n).map(|_| read!($tt)).collect::>() + }; + (($($tt:tt),+)) => { + ($(read!($tt)),*) + }; + (_1based) => { + read!(usize) - 1 + }; + (_bytes) => { + read!(String).into_bytes() + }; + ($ty:ty) => { + input.next().unwrap().parse::<$ty>().unwrap() + }; + }); - use proconio::input; - - input! { - q: usize, - lrs: [(usize, usize); q], - } + let q = read!(usize); + let lrs = read!([(usize, usize); q]); // サンプルケースでしか試してないので嘘かもしれない。 diff --git a/examples/abc120-d.rs b/examples/abc120-d.rs index 92e33ee..f79079b 100644 --- a/examples/abc120-d.rs +++ b/examples/abc120-d.rs @@ -2,55 +2,55 @@ use union_find::{QuickFindUf, UnionBySize, UnionFind as _}; +use std::io::{self, Read as _}; + +// `proconio::fastout` does not accept `macro_rules!` until Rust 1.40. +macro_rules! macro_rules_hack { + ($name:ident { $($tt:tt)* }) => { + macro_rules! $name { + $($tt)* + } + }; +} + #[proconio::fastout] fn main() { - // use std::io::{self, Read as _}; - // - // let mut input = "".to_owned(); - // io::stdin().read_to_string(&mut input).unwrap(); - // let mut input = input.split_whitespace(); - // macro_rules! read { - // ([$t:tt; $n:expr]) => { - // (0..$n).map(|_| read!($t)).collect::>() - // }; - // (($($t:tt),+)) => { - // ($(read!($t)),*) - // }; - // (_1based) => { - // read!(usize) - 1 - // }; - // (_bytes) => { - // read!(String).into_bytes() - // }; - // ($ty:ty) => { - // input.next().unwrap().parse::<$ty>().unwrap() - // }; - // } - // - // let (n, m) = (read!((usize, usize))); - // let abs = read!([(_1based, _1based); m]); - - use proconio::input; - use proconio::marker::Usize1; + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + macro_rules_hack!(read { + ([$tt:tt; $n:expr]) => { + (0..$n).map(|_| read!($tt)).collect::>() + }; + (($($tt:tt),+)) => { + ($(read!($tt)),*) + }; + (_1based) => { + read!(usize) - 1 + }; + (_bytes) => { + read!(String).into_bytes() + }; + ($ty:ty) => { + input.next().unwrap().parse::<$ty>().unwrap() + }; + }); - input! { - n: usize, - m: usize, - abs: [(Usize1, Usize1); m], - } + let (n, m) = read!((usize, usize)); + let abs = read!([(_1based, _1based); m]); - let mut u = QuickFindUf::::new(n); + let mut uf = QuickFindUf::::new(n); let mut k = n * (n - 1) / 2; - let mut r = vec![k]; - r.extend(abs.into_iter().rev().map(|(a, b)| { - let p = u.get(a).size() * u.get(b).size(); - if u.union(a, b) { + let mut ans_rev = vec![k]; + ans_rev.extend(abs.into_iter().rev().map(|(a, b)| { + let p = uf.get(a).size() * uf.get(b).size(); + if uf.union(a, b) { k -= p; } k })); - assert_eq!(r.pop(), Some(0)); - for r in r.into_iter().rev() { - println!("{}", r); + assert_eq!(ans_rev.pop(), Some(0)); + for x in ans_rev.into_iter().rev() { + println!("{}", x); } } diff --git a/examples/abc129-f.rs b/examples/abc129-f.rs index 019849a..0fbd84c 100644 --- a/examples/abc129-f.rs +++ b/examples/abc129-f.rs @@ -1,5 +1,6 @@ // https://atcoder.jp/contests/abc129/tasks/abc129_f +use defmac::defmac; use derive_more::Display; use ndarray::{array, Array2, LinalgScalar}; use num::{PrimInt, Unsigned}; @@ -7,42 +8,16 @@ use num_derive::{One, Zero}; use std::cell::Cell; use std::cmp; +use std::io::{self, Read as _}; use std::ops::{Add, Div, Mul, Sub}; fn main() { - // use std::io::{self, Read as _}; - // - // let mut input = "".to_owned(); - // io::stdin().read_to_string(&mut input).unwrap(); - // let mut input = input.split_whitespace(); - // macro_rules! read { - // ([$t:tt; $n:expr]) => { - // (0..$n).map(|_| read!($t)).collect::>() - // }; - // (($($t:tt),+)) => { - // ($(read!($t)),*) - // }; - // (_1based) => { - // read!(usize) - 1 - // }; - // (_bytes) => { - // read!(String).into_bytes() - // }; - // ($ty:ty) => { - // input.next().unwrap().parse::<$ty>().unwrap() - // }; - // } - // - // let (l, a, b, m) = read!((u64, u64, u64, u64)); - - use proconio::input; - - input! { - l: u64, - a: u64, - b: u64, - m: u64, - } + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + defmac!(read => input.next().unwrap().parse().unwrap()); + + let (l, a, b, m): (u64, u64, u64, u64) = (read!(), read!(), read!(), read!()); MOD.with(|cell| cell.set(m)); diff --git a/examples/abc142-d.rs b/examples/abc142-d.rs index a8fdb4e..fa4d093 100644 --- a/examples/abc142-d.rs +++ b/examples/abc142-d.rs @@ -1,42 +1,19 @@ // https://atcoder.jp/contests/abc142/tasks/abc142_d +use defmac::defmac; use primal::Sieve; use std::cmp::max; use std::collections::HashSet; +use std::io::{self, Read as _}; fn main() { - // use std::io::{self, Read as _}; - // - // let mut input = "".to_owned(); - // io::stdin().read_to_string(&mut input).unwrap(); - // let mut input = input.split_whitespace(); - // macro_rules! read { - // ([$t:tt; $n:expr]) => { - // (0..$n).map(|_| read!($t)).collect::>() - // }; - // (($($t:tt),+)) => { - // ($(read!($t)),*) - // }; - // (_1based) => { - // read!(usize) - 1 - // }; - // (_bytes) => { - // read!(String).into_bytes() - // }; - // ($ty:ty) => { - // input.next().unwrap().parse::<$ty>().unwrap() - // }; - // } - // - // let (n, m) = read!((usize, usize)); + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + defmac!(read => input.next().unwrap().parse().unwrap()); - use proconio::input; - - input! { - a: usize, - b: usize, - } + let (a, b): (usize, usize) = (read!(), read!()); // サンプルケースでしか試してないので嘘かもしれない。 diff --git a/examples/apg4b-a.rs b/examples/apg4b-a.rs index ef23780..41e2673 100644 --- a/examples/apg4b-a.rs +++ b/examples/apg4b-a.rs @@ -1,3 +1,5 @@ +// https://atcoder.jp/contests/APG4b/tasks/APG4b_a + use aho_corasick as _; use alga as _; use approx as _; diff --git a/examples/apg4b-ex25.rs b/examples/apg4b-ex25.rs index a19484e..81e2cd1 100644 --- a/examples/apg4b-ex25.rs +++ b/examples/apg4b-ex25.rs @@ -1,50 +1,41 @@ // https://atcoder.jp/contests/APG4b/tasks/APG4b_bx +#![allow(clippy::many_single_char_names)] + use fixedbitset::FixedBitSet; use itertools::Itertools as _; -fn main() { - // use std::io::{self, Read as _}; - // - // let mut input = "".to_owned(); - // io::stdin().read_to_string(&mut input).unwrap(); - // let mut input = input.split_whitespace(); - // macro_rules! read { - // ([$t:tt; $n:expr]) => { - // (0..$n).map(|_| read!($t)).collect::>() - // }; - // (($($t:tt),+)) => { - // ($(read!($t)),*) - // }; - // (_1based) => { - // read!(usize) - 1 - // }; - // (_bytes) => { - // read!(String).into_bytes() - // }; - // ($ty:ty) => { - // input.next().unwrap().parse::<$ty>().unwrap() - // }; - // } - // - // let n = read!(usize); - // let a = read!([usize; n]); - // let m = read!(usize); - // let b = read!([usize; m]); - // let arg0 = read!(String); - // let args = read!([usize; if arg0 == "subtract" { 1 } else { 0 }]); - - use proconio::input; +use std::io::{self, Read as _}; - input! { - n: usize, - a: [usize; n], - m: usize, - b: [usize; m], - arg0: String, - args: [usize; if arg0 == "subtract" { 1 } else { 0 }], +fn main() { + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + macro_rules! read { + ([$tt:tt; $n:expr]) => { + (0..$n).map(|_| read!($tt)).collect::>() + }; + (($($tt:tt),+)) => { + ($(read!($tt)),*) + }; + (_1based) => { + read!(usize) - 1 + }; + (_bytes) => { + read!(String).into_bytes() + }; + ($ty:ty) => { + input.next().unwrap().parse::<$ty>().unwrap() + }; } + let n = read!(usize); + let a = read!([usize; n]); + let m = read!(usize); + let b = read!([usize; m]); + let arg0 = read!(String); + let args = read!([usize; if arg0 == "subtract" { 1 } else { 0 }]); + let (a, b) = (a.into_iter().collect(), b.into_iter().collect()); print_set(&match (&*arg0, &*args) { diff --git a/examples/arc065-c.rs b/examples/arc065-c.rs index 46eb475..61c7395 100644 --- a/examples/arc065-c.rs +++ b/examples/arc065-c.rs @@ -3,39 +3,13 @@ use lazy_static::lazy_static; use regex::bytes::Regex; -#[proconio::fastout] -fn main() { - // use std::io::{self, Read as _}; - // - // let mut input = "".to_owned(); - // io::stdin().read_to_string(&mut input).unwrap(); - // let mut input = input.split_whitespace(); - // macro_rules! read { - // ([$t:tt; $n:expr]) => { - // (0..$n).map(|_| read!($t)).collect::>() - // }; - // (($($t:tt),+)) => { - // ($(read!($t)),*) - // }; - // (_1based) => { - // read!(usize) - 1 - // }; - // (_bytes) => { - // read!(String).into_bytes() - // }; - // ($ty:ty) => { - // input.next().unwrap().parse::<$ty>().unwrap() - // }; - // } - // - // let s = read!(_bytes); +use std::io::{self, Read as _}; - use proconio::input; - use proconio::marker::Bytes; +fn main() { + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); - input! { - s: Bytes, - } + let s = input.trim_end().as_bytes().to_owned(); lazy_static! { static ref R: Regex = Regex::new(r"\A(dream(er)?|eraser?)*\z").unwrap(); diff --git a/examples/arc084-c.rs b/examples/arc084-c.rs index dee0b17..558fd6e 100644 --- a/examples/arc084-c.rs +++ b/examples/arc084-c.rs @@ -2,42 +2,33 @@ use superslice::Ext as _; -fn main() { - // use std::io::{self, Read as _}; - // - // let mut input = "".to_owned(); - // io::stdin().read_to_string(&mut input).unwrap(); - // let mut input = input.split_whitespace(); - // macro_rules! read { - // ([$t:tt; $n:expr]) => { - // (0..$n).map(|_| read!($t)).collect::>() - // }; - // (($($t:tt),+)) => { - // ($(read!($t)),*) - // }; - // (_1based) => { - // read!(usize) - 1 - // }; - // (_bytes) => { - // read!(String).into_bytes() - // }; - // ($ty:ty) => { - // input.next().unwrap().parse::<$ty>().unwrap() - // }; - // } - // - // let n = read!(n); - // let (mut a, b, mut c) = read!(([u32; n], [u32; n], [u32; n])); - - use proconio::input; +use std::io::{self, Read as _}; - input! { - n: usize, - mut a: [u32; n], - b: [u32; n], - mut c: [u32; n], +fn main() { + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + macro_rules! read { + ([$tt:tt; $n:expr]) => { + (0..$n).map(|_| read!($tt)).collect::>() + }; + (($($tt:tt),+)) => { + ($(read!($tt)),*) + }; + (_1based) => { + read!(usize) - 1 + }; + (_bytes) => { + read!(String).into_bytes() + }; + ($ty:ty) => { + input.next().unwrap().parse::<$ty>().unwrap() + }; } + let n = read!(usize); + let (mut a, b, mut c) = read!(([u32; n], [u32; n], [u32; n])); + a.sort(); c.sort(); let ans = b diff --git a/examples/atc001-b.rs b/examples/atc001-b.rs index f630b23..9d16d6a 100644 --- a/examples/atc001-b.rs +++ b/examples/atc001-b.rs @@ -1,40 +1,43 @@ +// https://atcoder.jp/contests/atc001/tasks/unionfind_a + use petgraph::unionfind::UnionFind; +use std::io::{self, Read as _}; + +// `proconio::fastout` does not accept `macro_rules!` until Rust 1.40. +macro_rules! macro_rules_hack { + ($name:ident { $($tt:tt)* }) => { + macro_rules! $name { + $($tt)* + } + }; +} + #[proconio::fastout] fn main() { - // use std::io::{self, Read as _}; - // - // let mut input = "".to_owned(); - // io::stdin().read_to_string(&mut input).unwrap(); - // let mut input = input.split_whitespace(); - // macro_rules! read { - // ([$t:tt; $n:expr]) => { - // (0..$n).map(|_| read!($t)).collect::>() - // }; - // (($($t:tt),+)) => { - // ($(read!($t)),*) - // }; - // (_1based) => { - // read!(usize) - 1 - // }; - // (_bytes) => { - // read!(String).into_bytes() - // }; - // ($ty:ty) => { - // input.next().unwrap().parse::<$ty>().unwrap() - // }; - // } - // - // let (n, q) = read!((usize, usize)); - // let pabs = read!([(u8, usize, usize); q]); - - use proconio::input; + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + macro_rules_hack!(read { + ([$tt:tt; $n:expr]) => { + (0..$n).map(|_| read!($tt)).collect::>() + }; + (($($tt:tt),+)) => { + ($(read!($tt)),*) + }; + (_1based) => { + read!(usize) - 1 + }; + (_bytes) => { + read!(String).into_bytes() + }; + ($ty:ty) => { + input.next().unwrap().parse::<$ty>().unwrap() + }; + }); - input! { - n: usize, - q: usize, - pabs: [(u8, usize, usize); q], - } + let (n, q) = read!((usize, usize)); + let pabs = read!([(u8, usize, usize); q]); let mut uf = UnionFind::new(n); for (p, a, b) in pabs { diff --git a/examples/atc002-b.rs b/examples/atc002-b.rs index f2a2a7b..741dc70 100644 --- a/examples/atc002-b.rs +++ b/examples/atc002-b.rs @@ -1,29 +1,17 @@ // https://atcoder.jp/contests/atc002/tasks/atc002_b +use defmac::defmac; use num::BigUint; -#[proconio::fastout] -fn main() { - // use defmac::defmac; - // - // use std::io::{self, Read as _}; - // - // let mut input = "".to_owned(); - // io::stdin().read_to_string(&mut input).unwrap(); - // let mut input = input.split_whitespace(); - // defmac!(read => input.next().unwrap().parse().unwrap()); - // - // let n: BigUint = read!(); - // let m: BigUint = read!(); - // let p: BigUint = read!(); +use std::io::{self, Read as _}; - use proconio::input; +fn main() { + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + defmac!(read => input.next().unwrap().parse().unwrap()); - input! { - n: BigUint, - m: BigUint, - p: BigUint, - } + let (n, m, p): (BigUint, BigUint, BigUint) = (read!(), read!(), read!()); println!("{}", n.modpow(&p, &m)); } diff --git a/examples/practice-a.rs b/examples/practice-a.rs index 21a65b4..2e0d659 100644 --- a/examples/practice-a.rs +++ b/examples/practice-a.rs @@ -1,26 +1,16 @@ // https://atcoder.jp/contests/practice/tasks/practice_1 -#[proconio::fastout] -fn main() { - // use defmac::defmac; - // - // use std::io::{self, Read as _}; - // - // let mut input = "".to_owned(); - // io::stdin().read_to_string(&mut input).unwrap(); - // let mut input = input.split_whitespace(); - // defmac!(read => input.next().unwrap().parse().unwrap()); - // - // let (a, b, c, s): (u32, u32, u32, String) = (read!(), read!(), read!(), read!()); +use defmac::defmac; + +use std::io::{self, Read as _}; - use proconio::input; +fn main() { + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + defmac!(read => input.next().unwrap().parse().unwrap()); - input! { - a: u32, - b: u32, - c: u32, - s: String, - } + let (a, b, c, s): (u32, u32, u32, String) = (read!(), read!(), read!(), read!()); println!("{} {}", a + b + c, s); } From 833ebabfc5034c3d736d609822b8ede9d2fc634c Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Fri, 20 Dec 2019 20:04:57 +0900 Subject: [PATCH 08/39] Move ./examples/tests.ron to ./test-with-generated-opts.toml --- examples/tests.ron | 75 ---------------------- test-with-generated-opts.toml | 70 ++++++++++++++++++++ tools/test-with-generated-opts/Cargo.toml | 2 +- tools/test-with-generated-opts/src/main.rs | 22 ++++--- 4 files changed, 85 insertions(+), 84 deletions(-) delete mode 100644 examples/tests.ron create mode 100644 test-with-generated-opts.toml diff --git a/examples/tests.ron b/examples/tests.ron deleted file mode 100644 index ffb64b9..0000000 --- a/examples/tests.ron +++ /dev/null @@ -1,75 +0,0 @@ -// 手元でDropboxのテストケース(ある場合)で確認し、サンプルに含まれていないやつが大きいときはそれらをGitに入れない。 -// その場合CI上でもサンプルだけテストする。(Dropboxから引っ張るのも面倒だし何より誰のアカウントを使うかという問題がある) - -( - tests: { - "apg4b-a": ( - name: "APG4b: A - 1.00.はじめに", - matching: Exact, - ), - "apg4b-ex25": ( - name: "APG4b: EX25 - 集合の操作 / 3.05", - matching: Words, - ), - "apg4b-ex26": ( - name: "APG4b: EX26 - 電卓を作ろう3 / 3.06", - matching: Exact, - ), - "practice-a": ( - name: "practice contest: A - Welcome to AtCoder", - matching: Words, - ), - "atc001-b": ( - name: "ATC001: B - Union Find", - matching: Words, - ), - "atc002-b": ( - name: "ATC002: B - n^p mod m", - matching: Words, - ), - "arc065-c": ( - name: "ABC049 / ARC065: C - 白昼夢 / Daydream", - matching: Words, - ), - "abc054-c": ( - name: "ABC054: C - One-stroke Path", - matching: Words, - ), - "abc057-b": ( - name: "ABC057: B - Checkpoints", - matching: Words, - ), - "arc084-c": ( - name: "ABC077 / ARC084: C - Snuke Festival", - matching: Words, - ), - "abc084-d": ( - name: "ABC084: D - 2017-like Number", - matching: Words, - ), - "abc118-b": ( - name: "ABC118: B - Foods Loved by Everyone", - matching: Words, - ), - "abc120-d": ( - name: "ABC120: D - Decayed Bridges", - matching: Words, - ), - "abc121-b": ( - name: "ABC121: B - Can you solve this?", - matching: Words, - ), - "abc129-f": ( - name: "ABC129: F - Takahashi's Basics in Education and Learning", - matching: Words, - ), - "abc142-d": ( - name: "ABC142: D - Disjoint Set of Common Divisors", - matching: Words, - ), - "abc144-d": ( - name: "ABC144: D - Water Bottle", - matching: FloatOr(abs: 1e-6, rel: 1e-6), - ), - } -) diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml new file mode 100644 index 0000000..7ec1d23 --- /dev/null +++ b/test-with-generated-opts.toml @@ -0,0 +1,70 @@ +# 手元でDropboxのテストケース(ある場合)で確認し、サンプルに含まれていないやつが大きいときはそれらをGitに入れない。 +# その場合CI上でもサンプルだけテストする。(Dropboxから引っ張るのも面倒だし何より誰のアカウントを使うかという問題がある) + +[tests.abc054-c] +name = "ABC054: C - One-stroke Path" +matching = "Words" + +[tests.abc057-b] +name = "ABC057: B - Checkpoints" +matching = "Words" + +[tests.abc084-d] +name = "ABC084: D - 2017-like Number" +matching = "Words" + +[tests.abc118-b] +name = "ABC118: B - Foods Loved by Everyone" +matching = "Words" + +[tests.abc120-d] +name = "ABC120: D - Decayed Bridges" +matching = "Words" + +[tests.abc121-b] +name = "ABC121: B - Can you solve this?" +matching = "Words" + +[tests.abc129-f] +name = "ABC129: F - Takahashi's Basics in Education and Learning" +matching = "Words" + +[tests.abc142-d] +name = "ABC142: D - Disjoint Set of Common Divisors" +matching = "Words" + +[tests.abc144-d] +name = "ABC144: D - Water Bottle" +matching = { FloatOr = { abs = 1e-6, rel = 1e-6 } } + +[tests.apg4b-a] +name = "APG4b: A - 1.00.はじめに" +matching = "Exact" + +[tests.apg4b-ex25] +name = "APG4b: EX25 - 集合の操作 / 3.05" +matching = "Words" + +[tests.apg4b-ex26] +name = "APG4b: EX26 - 電卓を作ろう3 / 3.06" +matching = "Exact" + +[tests.arc065-c] +name = "ABC049 / ARC065: C - 白昼夢 / Daydream" +matching = "Words" + +[tests.arc084-c] +name = "ABC077 / ARC084: C - Snuke Festival" +matching = "Words" + +[tests.atc001-b] +name = "ATC001: B - Union Find" +matching = "Words" + +[tests.atc002-b] +name = "ATC002: B - n^p mod m" +matching = "Words" + +[tests.practice-a] +name = "practice contest: A - Welcome to AtCoder" +matching = "Words" diff --git a/tools/test-with-generated-opts/Cargo.toml b/tools/test-with-generated-opts/Cargo.toml index abd5a7a..2f03bcf 100644 --- a/tools/test-with-generated-opts/Cargo.toml +++ b/tools/test-with-generated-opts/Cargo.toml @@ -12,10 +12,10 @@ env_logger = "0.7.1" indexmap = { version = "1.3.0", features = ["serde-1"] } itertools = "0.8.2" log = "0.4.8" -ron = "0.5.1" serde = { version = "1.0.104", features = ["derive"] } serde_json = "1.0.44" shell-escape = "0.1.4" structopt = "0.3.5" tempdir = "0.3.7" +toml = "0.5.5" which = { version = "3.1.0", default-features = false } diff --git a/tools/test-with-generated-opts/src/main.rs b/tools/test-with-generated-opts/src/main.rs index e7dfa85..5afb50d 100644 --- a/tools/test-with-generated-opts/src/main.rs +++ b/tools/test-with-generated-opts/src/main.rs @@ -9,20 +9,26 @@ use structopt::StructOpt; use tempdir::TempDir; use std::collections::{BTreeMap, HashMap}; -use std::env; -use std::f64; use std::ffi::{OsStr, OsString}; -use std::fs::{self, File}; use std::io::{self, Read as _, Write as _}; use std::path::{Path, PathBuf}; use std::process::{Command, Output, Stdio}; use std::time::Instant; +use std::{env, f64, fs}; #[derive(StructOpt, Debug)] -struct Opt {} +struct Opt { + #[structopt( + long, + value_name("PATH"), + default_value("./test-with-generated-opts.toml"), + help("Path to the config") + )] + config: PathBuf, +} fn main() -> anyhow::Result<()> { - Opt::from_args(); + let Opt { config } = Opt::from_args(); env_logger::builder() .format(|buf, record| { @@ -48,10 +54,10 @@ fn main() -> anyhow::Result<()> { .filter_module("test_with_generated_opts", LevelFilter::Info) .init(); - let Tests { tests } = File::open("./examples/tests.ron") + let Tests { tests } = fs::read_to_string(&config) .map_err(anyhow::Error::from) - .and_then(|h| ron::de::from_reader(h).map_err(Into::into)) - .with_context(|| "Failed to read ./examples/tests.ron")?; + .and_then(|s| toml::from_str(&s).map_err(Into::into)) + .with_context(|| format!("Failed to read {}", config.display()))?; let tempdir = TempDir::new("atcoder-rust-base-test-with-generated-opts")?; From af6176b59b73c84bf00bb7b13907c1129d0647ca Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Fri, 20 Dec 2019 22:50:48 +0900 Subject: [PATCH 09/39] Modify the format of test-with-generated-opts.toml --- test-with-generated-opts.toml | 51 ++++++++++----- tools/test-with-generated-opts/src/main.rs | 75 ++++++++++++++-------- 2 files changed, 83 insertions(+), 43 deletions(-) diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml index 7ec1d23..5b31d6a 100644 --- a/test-with-generated-opts.toml +++ b/test-with-generated-opts.toml @@ -1,70 +1,87 @@ # 手元でDropboxのテストケース(ある場合)で確認し、サンプルに含まれていないやつが大きいときはそれらをGitに入れない。 # その場合CI上でもサンプルだけテストする。(Dropboxから引っ張るのも面倒だし何より誰のアカウントを使うかという問題がある) -[tests.abc054-c] +[examples.abc054-c] name = "ABC054: C - One-stroke Path" +url = "https://atcoder.jp/contests/abc054/tasks/abc054_c" matching = "Words" -[tests.abc057-b] +[examples.abc057-b] name = "ABC057: B - Checkpoints" +url = "https://atcoder.jp/contests/abc057/tasks/abc057_b" matching = "Words" -[tests.abc084-d] +[examples.abc084-d] name = "ABC084: D - 2017-like Number" +url = "https://atcoder.jp/contests/abc084/tasks/abc084_d" matching = "Words" -[tests.abc118-b] +[examples.abc118-b] name = "ABC118: B - Foods Loved by Everyone" +url = "https://atcoder.jp/contests/abc118/tasks/abc118_b" matching = "Words" -[tests.abc120-d] +[examples.abc120-d] name = "ABC120: D - Decayed Bridges" +url = "https://atcoder.jp/contests/abc120/tasks/abc120_d" matching = "Words" -[tests.abc121-b] +[examples.abc121-b] name = "ABC121: B - Can you solve this?" +url = "https://atcoder.jp/contests/abc121/tasks/abc121_b" matching = "Words" -[tests.abc129-f] +[examples.abc129-f] name = "ABC129: F - Takahashi's Basics in Education and Learning" +url = "https://atcoder.jp/contests/abc129/tasks/abc129_f" matching = "Words" -[tests.abc142-d] +[examples.abc142-d] name = "ABC142: D - Disjoint Set of Common Divisors" +url = "https://atcoder.jp/contests/abc142/tasks/abc142_d" matching = "Words" -[tests.abc144-d] +[examples.abc144-d] name = "ABC144: D - Water Bottle" +url = "https://atcoder.jp/contests/abc144/tasks/abc144_d" matching = { FloatOr = { abs = 1e-6, rel = 1e-6 } } -[tests.apg4b-a] +[examples.apg4b-a] name = "APG4b: A - 1.00.はじめに" +url = "https://atcoder.jp/contests/APG4b/tasks/APG4b_a" matching = "Exact" -[tests.apg4b-ex25] +[examples.apg4b-ex25] name = "APG4b: EX25 - 集合の操作 / 3.05" +url = "https://atcoder.jp/contests/APG4b/tasks/APG4b_bx" matching = "Words" -[tests.apg4b-ex26] +[examples.apg4b-ex26] name = "APG4b: EX26 - 電卓を作ろう3 / 3.06" +url = "https://atcoder.jp/contests/APG4b/tasks/APG4b_bw" matching = "Exact" -[tests.arc065-c] +[examples.arc065-c] name = "ABC049 / ARC065: C - 白昼夢 / Daydream" +url = "https://atcoder.jp/contests/arc065/tasks/arc065_a" matching = "Words" -[tests.arc084-c] +[examples.arc084-c] name = "ABC077 / ARC084: C - Snuke Festival" +url = "https://atcoder.jp/contests/arc084/tasks/arc084_a" matching = "Words" -[tests.atc001-b] +[examples.atc001-b] name = "ATC001: B - Union Find" +url = "https://atcoder.jp/contests/atc001/tasks/unionfind_a" matching = "Words" -[tests.atc002-b] +[examples.atc002-b] name = "ATC002: B - n^p mod m" +url = "https://atcoder.jp/contests/atc002/tasks/atc002_b" matching = "Words" -[tests.practice-a] +[examples.practice-a] name = "practice contest: A - Welcome to AtCoder" +url = "https://atcoder.jp/contests/practice/tasks/practice_1" matching = "Words" diff --git a/tools/test-with-generated-opts/src/main.rs b/tools/test-with-generated-opts/src/main.rs index 5afb50d..0cae21a 100644 --- a/tools/test-with-generated-opts/src/main.rs +++ b/tools/test-with-generated-opts/src/main.rs @@ -54,25 +54,34 @@ fn main() -> anyhow::Result<()> { .filter_module("test_with_generated_opts", LevelFilter::Info) .init(); - let Tests { tests } = fs::read_to_string(&config) + let Config { examples } = fs::read_to_string(&config) .map_err(anyhow::Error::from) .and_then(|s| toml::from_str(&s).map_err(Into::into)) .with_context(|| format!("Failed to read {}", config.display()))?; let tempdir = TempDir::new("atcoder-rust-base-test-with-generated-opts")?; - let tests = tests + let tests = examples .into_iter() - .map(|(slug, Test { name, matching })| { - let src = Path::new("./examples").join(&slug).with_extension("rs"); - let testsets = Path::new("./examples/testsets").join(&slug); - let binary = compile(&src, tempdir.path(), &slug)?; - Ok((name, matching, testsets, binary)) - }) + .map( + |( + slug, + Example { + name, + url, + matching, + }, + )| { + let src = Path::new("./examples").join(&slug).with_extension("rs"); + let testsets = Path::new("./examples/testsets").join(&slug); + let binary = compile(&src, tempdir.path(), &slug)?; + Ok((name, url, matching, testsets, binary)) + }, + ) .collect::>>()?; - for (name, matching, testsets, binary) in tests { - test(&name, matching, &testsets, &binary)?; + for (name, url, matching, testsets, binary) in tests { + test(&name, &url, matching, &testsets, &binary)?; } Ok(()) } @@ -142,20 +151,31 @@ fn compile(src: &Path, tempdir: &Path, dir_name: &str) -> anyhow::Result anyhow::Result<()> { +fn test( + task_name: &str, + url: &str, + matching: Matching, + testsets: &Path, + binary: &Path, +) -> anyhow::Result<()> { let testsets = { - let find_files = |dir: &str| -> _ { - fs::read_dir(testsets.join(dir))? - .map(|entry| { - let path = entry?.path(); - let name = path - .file_stem() - .unwrap_or_default() - .to_string_lossy() - .into_owned(); - Ok((name, path)) + let find_files = |dir_file_name: &str| -> _ { + let dir = testsets.join(dir_file_name); + fs::read_dir(&dir) + .and_then(|read_dir| { + read_dir + .map(|entry| { + let path = entry?.path(); + let name = path + .file_stem() + .unwrap_or_default() + .to_string_lossy() + .into_owned(); + Ok((name, path)) + }) + .collect::>>() }) - .collect::>>() + .with_context(|| format!("Failed to read {}", dir.display())) }; let (ins, outs) = (find_files("in")?, find_files("out")?); @@ -168,7 +188,9 @@ fn test(task_name: &str, matching: Matching, testsets: &Path, binary: &Path) -> .collect::>() }; - info!("Testing {} for {:?}", binary.display(), task_name); + info!("Testing {}", binary.display()); + info!(" Name: {:?}", task_name); + info!(" URL: {}", url); for (test_name, (path_in, path_out)) in testsets { fn read_to_string(path: &Path) -> anyhow::Result { @@ -218,13 +240,14 @@ fn test(task_name: &str, matching: Matching, testsets: &Path, binary: &Path) -> } #[derive(Debug, Deserialize)] -struct Tests { - tests: IndexMap, +struct Config { + examples: IndexMap, } #[derive(Debug, Deserialize)] -struct Test { +struct Example { name: String, + url: String, matching: Matching, } From b43ac7eb285eae667acab3550b85f7fb888b2124 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Sat, 21 Dec 2019 00:11:14 +0900 Subject: [PATCH 10/39] Remove `practice-a` from the examples --- examples/practice-a.rs | 16 ---------------- examples/testsets/practice-a/in/00_sample_1.txt | 3 --- examples/testsets/practice-a/in/00_sample_2.txt | 3 --- examples/testsets/practice-a/out/00_sample_1.txt | 1 - examples/testsets/practice-a/out/00_sample_2.txt | 1 - test-with-generated-opts.toml | 5 ----- 6 files changed, 29 deletions(-) delete mode 100644 examples/practice-a.rs delete mode 100644 examples/testsets/practice-a/in/00_sample_1.txt delete mode 100644 examples/testsets/practice-a/in/00_sample_2.txt delete mode 100644 examples/testsets/practice-a/out/00_sample_1.txt delete mode 100644 examples/testsets/practice-a/out/00_sample_2.txt diff --git a/examples/practice-a.rs b/examples/practice-a.rs deleted file mode 100644 index 2e0d659..0000000 --- a/examples/practice-a.rs +++ /dev/null @@ -1,16 +0,0 @@ -// https://atcoder.jp/contests/practice/tasks/practice_1 - -use defmac::defmac; - -use std::io::{self, Read as _}; - -fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); - let mut input = input.split_whitespace(); - defmac!(read => input.next().unwrap().parse().unwrap()); - - let (a, b, c, s): (u32, u32, u32, String) = (read!(), read!(), read!(), read!()); - - println!("{} {}", a + b + c, s); -} diff --git a/examples/testsets/practice-a/in/00_sample_1.txt b/examples/testsets/practice-a/in/00_sample_1.txt deleted file mode 100644 index b75af29..0000000 --- a/examples/testsets/practice-a/in/00_sample_1.txt +++ /dev/null @@ -1,3 +0,0 @@ -1 -2 3 -test diff --git a/examples/testsets/practice-a/in/00_sample_2.txt b/examples/testsets/practice-a/in/00_sample_2.txt deleted file mode 100644 index a4250ca..0000000 --- a/examples/testsets/practice-a/in/00_sample_2.txt +++ /dev/null @@ -1,3 +0,0 @@ -72 -128 256 -myonmyon diff --git a/examples/testsets/practice-a/out/00_sample_1.txt b/examples/testsets/practice-a/out/00_sample_1.txt deleted file mode 100644 index 58fffac..0000000 --- a/examples/testsets/practice-a/out/00_sample_1.txt +++ /dev/null @@ -1 +0,0 @@ -6 test diff --git a/examples/testsets/practice-a/out/00_sample_2.txt b/examples/testsets/practice-a/out/00_sample_2.txt deleted file mode 100644 index a5c645d..0000000 --- a/examples/testsets/practice-a/out/00_sample_2.txt +++ /dev/null @@ -1 +0,0 @@ -456 myonmyon diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml index 5b31d6a..ce4670f 100644 --- a/test-with-generated-opts.toml +++ b/test-with-generated-opts.toml @@ -80,8 +80,3 @@ matching = "Words" name = "ATC002: B - n^p mod m" url = "https://atcoder.jp/contests/atc002/tasks/atc002_b" matching = "Words" - -[examples.practice-a] -name = "practice contest: A - Welcome to AtCoder" -url = "https://atcoder.jp/contests/practice/tasks/practice_1" -matching = "Words" From ed595a605f21dd9c15b8d4b72eb3c5abc844a314 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Sat, 21 Dec 2019 19:21:41 +0900 Subject: [PATCH 11/39] Scrape sample cases from AtCoder --- .github/workflows/ci.yml | 4 +- examples/testsets/abc054-c/in/sample_01.txt | 4 - examples/testsets/abc054-c/in/sample_02.txt | 8 - examples/testsets/abc054-c/out/sample_01.txt | 1 - examples/testsets/abc054-c/out/sample_02.txt | 1 - examples/testsets/abc057-b/in/sample_01.txt | 5 - examples/testsets/abc057-b/in/sample_02.txt | 8 - examples/testsets/abc057-b/in/sample_03.txt | 11 - examples/testsets/abc057-b/out/sample_01.txt | 2 - examples/testsets/abc057-b/out/sample_02.txt | 3 - examples/testsets/abc057-b/out/sample_03.txt | 5 - examples/testsets/abc084-d/in/sample_01.txt | 2 - examples/testsets/abc084-d/in/sample_02.txt | 5 - examples/testsets/abc084-d/in/sample_03.txt | 7 - examples/testsets/abc084-d/out/sample_01.txt | 1 - examples/testsets/abc084-d/out/sample_02.txt | 4 - examples/testsets/abc084-d/out/sample_03.txt | 6 - examples/testsets/abc118-b/in/sample_01.txt | 4 - examples/testsets/abc118-b/in/sample_02.txt | 6 - examples/testsets/abc118-b/in/sample_03.txt | 2 - examples/testsets/abc118-b/out/sample_01.txt | 1 - examples/testsets/abc118-b/out/sample_02.txt | 1 - examples/testsets/abc118-b/out/sample_03.txt | 1 - examples/testsets/abc120-d/in/sample_01.txt | 6 - examples/testsets/abc120-d/in/sample_02.txt | 6 - examples/testsets/abc120-d/in/sample_03.txt | 2 - examples/testsets/abc120-d/out/sample_01.txt | 5 - examples/testsets/abc120-d/out/sample_02.txt | 5 - examples/testsets/abc120-d/out/sample_03.txt | 1 - examples/testsets/abc121-b/in/sample_01.txt | 4 - examples/testsets/abc121-b/in/sample_02.txt | 7 - examples/testsets/abc121-b/in/sample_03.txt | 5 - examples/testsets/abc121-b/out/sample_01.txt | 1 - examples/testsets/abc121-b/out/sample_02.txt | 1 - examples/testsets/abc121-b/out/sample_03.txt | 1 - examples/testsets/abc129-f/in/sample_01.txt | 1 - examples/testsets/abc129-f/in/sample_02.txt | 1 - examples/testsets/abc129-f/in/sample_03.txt | 1 - .../testsets/abc129-f/in/sub1_killer_01.txt | 1 - .../testsets/abc129-f/in/sub1_killer_02.txt | 1 - .../testsets/abc129-f/in/sub1_killer_03.txt | 1 - .../testsets/abc129-f/in/sub1_killer_04.txt | 1 - .../testsets/abc129-f/in/sub1_killer_05.txt | 1 - .../testsets/abc129-f/in/sub1_killer_06.txt | 1 - .../testsets/abc129-f/in/sub1_killer_07.txt | 1 - .../testsets/abc129-f/in/sub1_large_01.txt | 1 - .../testsets/abc129-f/in/sub1_large_02.txt | 1 - .../testsets/abc129-f/in/sub1_large_03.txt | 1 - .../testsets/abc129-f/in/sub1_large_04.txt | 1 - .../testsets/abc129-f/in/sub1_large_05.txt | 1 - .../testsets/abc129-f/in/sub1_large_06.txt | 1 - .../testsets/abc129-f/in/sub1_large_07.txt | 1 - .../testsets/abc129-f/in/sub1_large_08.txt | 1 - .../testsets/abc129-f/in/sub1_large_09.txt | 1 - .../testsets/abc129-f/in/sub1_rand_01.txt | 1 - .../testsets/abc129-f/in/sub1_rand_02.txt | 1 - .../testsets/abc129-f/in/sub1_rand_03.txt | 1 - .../testsets/abc129-f/in/sub1_rand_04.txt | 1 - .../testsets/abc129-f/in/sub1_rand_05.txt | 1 - .../testsets/abc129-f/in/sub1_rand_06.txt | 1 - .../testsets/abc129-f/in/sub1_rand_07.txt | 1 - .../testsets/abc129-f/in/sub1_rand_08.txt | 1 - .../testsets/abc129-f/in/sub1_rand_09.txt | 1 - .../testsets/abc129-f/in/sub1_rand_10.txt | 1 - .../testsets/abc129-f/in/sub1_small_01.txt | 1 - .../testsets/abc129-f/in/sub1_small_02.txt | 1 - .../testsets/abc129-f/in/sub1_small_03.txt | 1 - .../testsets/abc129-f/in/sub1_small_04.txt | 1 - .../testsets/abc129-f/in/sub1_small_05.txt | 1 - .../testsets/abc129-f/in/sub1_small_06.txt | 1 - examples/testsets/abc129-f/out/sample_01.txt | 1 - examples/testsets/abc129-f/out/sample_02.txt | 1 - examples/testsets/abc129-f/out/sample_03.txt | 1 - .../testsets/abc129-f/out/sub1_killer_01.txt | 1 - .../testsets/abc129-f/out/sub1_killer_02.txt | 1 - .../testsets/abc129-f/out/sub1_killer_03.txt | 1 - .../testsets/abc129-f/out/sub1_killer_04.txt | 1 - .../testsets/abc129-f/out/sub1_killer_05.txt | 1 - .../testsets/abc129-f/out/sub1_killer_06.txt | 1 - .../testsets/abc129-f/out/sub1_killer_07.txt | 1 - .../testsets/abc129-f/out/sub1_large_01.txt | 1 - .../testsets/abc129-f/out/sub1_large_02.txt | 1 - .../testsets/abc129-f/out/sub1_large_03.txt | 1 - .../testsets/abc129-f/out/sub1_large_04.txt | 1 - .../testsets/abc129-f/out/sub1_large_05.txt | 1 - .../testsets/abc129-f/out/sub1_large_06.txt | 1 - .../testsets/abc129-f/out/sub1_large_07.txt | 1 - .../testsets/abc129-f/out/sub1_large_08.txt | 1 - .../testsets/abc129-f/out/sub1_large_09.txt | 1 - .../testsets/abc129-f/out/sub1_rand_01.txt | 1 - .../testsets/abc129-f/out/sub1_rand_02.txt | 1 - .../testsets/abc129-f/out/sub1_rand_03.txt | 1 - .../testsets/abc129-f/out/sub1_rand_04.txt | 1 - .../testsets/abc129-f/out/sub1_rand_05.txt | 1 - .../testsets/abc129-f/out/sub1_rand_06.txt | 1 - .../testsets/abc129-f/out/sub1_rand_07.txt | 1 - .../testsets/abc129-f/out/sub1_rand_08.txt | 1 - .../testsets/abc129-f/out/sub1_rand_09.txt | 1 - .../testsets/abc129-f/out/sub1_rand_10.txt | 1 - .../testsets/abc129-f/out/sub1_small_01.txt | 1 - .../testsets/abc129-f/out/sub1_small_02.txt | 1 - .../testsets/abc129-f/out/sub1_small_03.txt | 1 - .../testsets/abc129-f/out/sub1_small_04.txt | 1 - .../testsets/abc129-f/out/sub1_small_05.txt | 1 - .../testsets/abc129-f/out/sub1_small_06.txt | 1 - examples/testsets/abc142-d/in/sample_01.txt | 1 - examples/testsets/abc142-d/in/sample_02.txt | 1 - examples/testsets/abc142-d/in/sample_03.txt | 1 - examples/testsets/abc142-d/out/sample_01.txt | 1 - examples/testsets/abc142-d/out/sample_02.txt | 1 - examples/testsets/abc142-d/out/sample_03.txt | 1 - examples/testsets/abc144-d/in/handmade03.txt | 1 - examples/testsets/abc144-d/in/handmade04.txt | 1 - examples/testsets/abc144-d/in/random05.txt | 1 - examples/testsets/abc144-d/in/random06.txt | 1 - examples/testsets/abc144-d/in/random07.txt | 1 - examples/testsets/abc144-d/in/random08.txt | 1 - examples/testsets/abc144-d/in/random09.txt | 1 - examples/testsets/abc144-d/in/random10.txt | 1 - examples/testsets/abc144-d/in/random11.txt | 1 - examples/testsets/abc144-d/in/random12.txt | 1 - examples/testsets/abc144-d/in/random13.txt | 1 - examples/testsets/abc144-d/in/random14.txt | 1 - examples/testsets/abc144-d/in/sample00.txt | 1 - examples/testsets/abc144-d/in/sample01.txt | 1 - examples/testsets/abc144-d/in/sample02.txt | 1 - examples/testsets/abc144-d/out/handmade03.txt | 1 - examples/testsets/abc144-d/out/handmade04.txt | 1 - examples/testsets/abc144-d/out/random05.txt | 1 - examples/testsets/abc144-d/out/random06.txt | 1 - examples/testsets/abc144-d/out/random07.txt | 1 - examples/testsets/abc144-d/out/random08.txt | 1 - examples/testsets/abc144-d/out/random09.txt | 1 - examples/testsets/abc144-d/out/random10.txt | 1 - examples/testsets/abc144-d/out/random11.txt | 1 - examples/testsets/abc144-d/out/random12.txt | 1 - examples/testsets/abc144-d/out/random13.txt | 1 - examples/testsets/abc144-d/out/random14.txt | 1 - examples/testsets/abc144-d/out/sample00.txt | 1 - examples/testsets/abc144-d/out/sample01.txt | 1 - examples/testsets/abc144-d/out/sample02.txt | 1 - examples/testsets/apg4b-a/in/sample_01.txt | 0 examples/testsets/apg4b-a/out/sample_01.txt | 1 - examples/testsets/apg4b-ex25/in/sample_01.txt | 5 - examples/testsets/apg4b-ex25/in/sample_02.txt | 5 - examples/testsets/apg4b-ex25/in/sample_03.txt | 5 - examples/testsets/apg4b-ex25/in/sample_04.txt | 5 - examples/testsets/apg4b-ex25/in/sample_05.txt | 5 - examples/testsets/apg4b-ex25/in/sample_06.txt | 5 - .../testsets/apg4b-ex25/out/sample_01.txt | 1 - .../testsets/apg4b-ex25/out/sample_02.txt | 1 - .../testsets/apg4b-ex25/out/sample_03.txt | 1 - .../testsets/apg4b-ex25/out/sample_04.txt | 1 - .../testsets/apg4b-ex25/out/sample_05.txt | 1 - .../testsets/apg4b-ex25/out/sample_06.txt | 1 - examples/testsets/apg4b-ex26/in/sample_01.txt | 5 - examples/testsets/apg4b-ex26/in/sample_02.txt | 3 - examples/testsets/apg4b-ex26/in/sample_03.txt | 2 - examples/testsets/apg4b-ex26/in/sample_04.txt | 2 - examples/testsets/apg4b-ex26/in/sample_05.txt | 3 - examples/testsets/apg4b-ex26/in/sample_06.txt | 3 - examples/testsets/apg4b-ex26/in/sample_07.txt | 5 - examples/testsets/apg4b-ex26/in/sample_08.txt | 5 - examples/testsets/apg4b-ex26/in/sample_09.txt | 7 - .../testsets/apg4b-ex26/out/sample_01.txt | 2 - .../testsets/apg4b-ex26/out/sample_02.txt | 2 - .../testsets/apg4b-ex26/out/sample_03.txt | 1 - .../testsets/apg4b-ex26/out/sample_04.txt | 1 - .../testsets/apg4b-ex26/out/sample_05.txt | 1 - .../testsets/apg4b-ex26/out/sample_06.txt | 1 - .../testsets/apg4b-ex26/out/sample_07.txt | 1 - .../testsets/apg4b-ex26/out/sample_08.txt | 1 - .../testsets/apg4b-ex26/out/sample_09.txt | 3 - examples/testsets/arc065-c/in/subtask0_0.txt | 1 - examples/testsets/arc065-c/in/subtask0_1.txt | 1 - examples/testsets/arc065-c/in/subtask0_2.txt | 1 - examples/testsets/arc065-c/out/subtask0_0.txt | 1 - examples/testsets/arc065-c/out/subtask0_1.txt | 1 - examples/testsets/arc065-c/out/subtask0_2.txt | 1 - examples/testsets/arc084-c/in/s1.txt | 4 - examples/testsets/arc084-c/in/s2.txt | 4 - examples/testsets/arc084-c/in/s3.txt | 4 - examples/testsets/arc084-c/out/s1.txt | 1 - examples/testsets/arc084-c/out/s2.txt | 1 - examples/testsets/arc084-c/out/s3.txt | 1 - .../testsets/atc001-b/in/00_sample_01.txt | 10 - .../testsets/atc001-b/out/00_sample_01.txt | 4 - examples/testsets/atc002-b/in/sample_01.txt | 1 - examples/testsets/atc002-b/in/sample_02.txt | 1 - examples/testsets/atc002-b/out/sample_01.txt | 1 - examples/testsets/atc002-b/out/sample_02.txt | 1 - test-with-generated-opts.toml | 7 +- tools/test-with-generated-opts/Cargo.toml | 7 +- tools/test-with-generated-opts/src/main.rs | 509 +++++++++++++++--- 194 files changed, 455 insertions(+), 434 deletions(-) delete mode 100644 examples/testsets/abc054-c/in/sample_01.txt delete mode 100644 examples/testsets/abc054-c/in/sample_02.txt delete mode 100644 examples/testsets/abc054-c/out/sample_01.txt delete mode 100644 examples/testsets/abc054-c/out/sample_02.txt delete mode 100644 examples/testsets/abc057-b/in/sample_01.txt delete mode 100644 examples/testsets/abc057-b/in/sample_02.txt delete mode 100644 examples/testsets/abc057-b/in/sample_03.txt delete mode 100644 examples/testsets/abc057-b/out/sample_01.txt delete mode 100644 examples/testsets/abc057-b/out/sample_02.txt delete mode 100644 examples/testsets/abc057-b/out/sample_03.txt delete mode 100644 examples/testsets/abc084-d/in/sample_01.txt delete mode 100644 examples/testsets/abc084-d/in/sample_02.txt delete mode 100644 examples/testsets/abc084-d/in/sample_03.txt delete mode 100644 examples/testsets/abc084-d/out/sample_01.txt delete mode 100644 examples/testsets/abc084-d/out/sample_02.txt delete mode 100644 examples/testsets/abc084-d/out/sample_03.txt delete mode 100644 examples/testsets/abc118-b/in/sample_01.txt delete mode 100644 examples/testsets/abc118-b/in/sample_02.txt delete mode 100644 examples/testsets/abc118-b/in/sample_03.txt delete mode 100644 examples/testsets/abc118-b/out/sample_01.txt delete mode 100644 examples/testsets/abc118-b/out/sample_02.txt delete mode 100644 examples/testsets/abc118-b/out/sample_03.txt delete mode 100644 examples/testsets/abc120-d/in/sample_01.txt delete mode 100644 examples/testsets/abc120-d/in/sample_02.txt delete mode 100644 examples/testsets/abc120-d/in/sample_03.txt delete mode 100644 examples/testsets/abc120-d/out/sample_01.txt delete mode 100644 examples/testsets/abc120-d/out/sample_02.txt delete mode 100644 examples/testsets/abc120-d/out/sample_03.txt delete mode 100644 examples/testsets/abc121-b/in/sample_01.txt delete mode 100644 examples/testsets/abc121-b/in/sample_02.txt delete mode 100644 examples/testsets/abc121-b/in/sample_03.txt delete mode 100644 examples/testsets/abc121-b/out/sample_01.txt delete mode 100644 examples/testsets/abc121-b/out/sample_02.txt delete mode 100644 examples/testsets/abc121-b/out/sample_03.txt delete mode 100644 examples/testsets/abc129-f/in/sample_01.txt delete mode 100644 examples/testsets/abc129-f/in/sample_02.txt delete mode 100644 examples/testsets/abc129-f/in/sample_03.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_killer_01.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_killer_02.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_killer_03.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_killer_04.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_killer_05.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_killer_06.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_killer_07.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_large_01.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_large_02.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_large_03.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_large_04.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_large_05.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_large_06.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_large_07.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_large_08.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_large_09.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_rand_01.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_rand_02.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_rand_03.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_rand_04.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_rand_05.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_rand_06.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_rand_07.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_rand_08.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_rand_09.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_rand_10.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_small_01.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_small_02.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_small_03.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_small_04.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_small_05.txt delete mode 100644 examples/testsets/abc129-f/in/sub1_small_06.txt delete mode 100644 examples/testsets/abc129-f/out/sample_01.txt delete mode 100644 examples/testsets/abc129-f/out/sample_02.txt delete mode 100644 examples/testsets/abc129-f/out/sample_03.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_killer_01.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_killer_02.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_killer_03.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_killer_04.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_killer_05.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_killer_06.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_killer_07.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_large_01.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_large_02.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_large_03.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_large_04.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_large_05.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_large_06.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_large_07.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_large_08.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_large_09.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_rand_01.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_rand_02.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_rand_03.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_rand_04.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_rand_05.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_rand_06.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_rand_07.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_rand_08.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_rand_09.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_rand_10.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_small_01.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_small_02.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_small_03.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_small_04.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_small_05.txt delete mode 100644 examples/testsets/abc129-f/out/sub1_small_06.txt delete mode 100644 examples/testsets/abc142-d/in/sample_01.txt delete mode 100644 examples/testsets/abc142-d/in/sample_02.txt delete mode 100644 examples/testsets/abc142-d/in/sample_03.txt delete mode 100644 examples/testsets/abc142-d/out/sample_01.txt delete mode 100644 examples/testsets/abc142-d/out/sample_02.txt delete mode 100644 examples/testsets/abc142-d/out/sample_03.txt delete mode 100644 examples/testsets/abc144-d/in/handmade03.txt delete mode 100644 examples/testsets/abc144-d/in/handmade04.txt delete mode 100644 examples/testsets/abc144-d/in/random05.txt delete mode 100644 examples/testsets/abc144-d/in/random06.txt delete mode 100644 examples/testsets/abc144-d/in/random07.txt delete mode 100644 examples/testsets/abc144-d/in/random08.txt delete mode 100644 examples/testsets/abc144-d/in/random09.txt delete mode 100644 examples/testsets/abc144-d/in/random10.txt delete mode 100644 examples/testsets/abc144-d/in/random11.txt delete mode 100644 examples/testsets/abc144-d/in/random12.txt delete mode 100644 examples/testsets/abc144-d/in/random13.txt delete mode 100644 examples/testsets/abc144-d/in/random14.txt delete mode 100644 examples/testsets/abc144-d/in/sample00.txt delete mode 100644 examples/testsets/abc144-d/in/sample01.txt delete mode 100644 examples/testsets/abc144-d/in/sample02.txt delete mode 100644 examples/testsets/abc144-d/out/handmade03.txt delete mode 100644 examples/testsets/abc144-d/out/handmade04.txt delete mode 100644 examples/testsets/abc144-d/out/random05.txt delete mode 100644 examples/testsets/abc144-d/out/random06.txt delete mode 100644 examples/testsets/abc144-d/out/random07.txt delete mode 100644 examples/testsets/abc144-d/out/random08.txt delete mode 100644 examples/testsets/abc144-d/out/random09.txt delete mode 100644 examples/testsets/abc144-d/out/random10.txt delete mode 100644 examples/testsets/abc144-d/out/random11.txt delete mode 100644 examples/testsets/abc144-d/out/random12.txt delete mode 100644 examples/testsets/abc144-d/out/random13.txt delete mode 100644 examples/testsets/abc144-d/out/random14.txt delete mode 100644 examples/testsets/abc144-d/out/sample00.txt delete mode 100644 examples/testsets/abc144-d/out/sample01.txt delete mode 100644 examples/testsets/abc144-d/out/sample02.txt delete mode 100644 examples/testsets/apg4b-a/in/sample_01.txt delete mode 100644 examples/testsets/apg4b-a/out/sample_01.txt delete mode 100644 examples/testsets/apg4b-ex25/in/sample_01.txt delete mode 100644 examples/testsets/apg4b-ex25/in/sample_02.txt delete mode 100644 examples/testsets/apg4b-ex25/in/sample_03.txt delete mode 100644 examples/testsets/apg4b-ex25/in/sample_04.txt delete mode 100644 examples/testsets/apg4b-ex25/in/sample_05.txt delete mode 100644 examples/testsets/apg4b-ex25/in/sample_06.txt delete mode 100644 examples/testsets/apg4b-ex25/out/sample_01.txt delete mode 100644 examples/testsets/apg4b-ex25/out/sample_02.txt delete mode 100644 examples/testsets/apg4b-ex25/out/sample_03.txt delete mode 100644 examples/testsets/apg4b-ex25/out/sample_04.txt delete mode 100644 examples/testsets/apg4b-ex25/out/sample_05.txt delete mode 100644 examples/testsets/apg4b-ex25/out/sample_06.txt delete mode 100644 examples/testsets/apg4b-ex26/in/sample_01.txt delete mode 100644 examples/testsets/apg4b-ex26/in/sample_02.txt delete mode 100644 examples/testsets/apg4b-ex26/in/sample_03.txt delete mode 100644 examples/testsets/apg4b-ex26/in/sample_04.txt delete mode 100644 examples/testsets/apg4b-ex26/in/sample_05.txt delete mode 100644 examples/testsets/apg4b-ex26/in/sample_06.txt delete mode 100644 examples/testsets/apg4b-ex26/in/sample_07.txt delete mode 100644 examples/testsets/apg4b-ex26/in/sample_08.txt delete mode 100644 examples/testsets/apg4b-ex26/in/sample_09.txt delete mode 100644 examples/testsets/apg4b-ex26/out/sample_01.txt delete mode 100644 examples/testsets/apg4b-ex26/out/sample_02.txt delete mode 100644 examples/testsets/apg4b-ex26/out/sample_03.txt delete mode 100644 examples/testsets/apg4b-ex26/out/sample_04.txt delete mode 100644 examples/testsets/apg4b-ex26/out/sample_05.txt delete mode 100644 examples/testsets/apg4b-ex26/out/sample_06.txt delete mode 100644 examples/testsets/apg4b-ex26/out/sample_07.txt delete mode 100644 examples/testsets/apg4b-ex26/out/sample_08.txt delete mode 100644 examples/testsets/apg4b-ex26/out/sample_09.txt delete mode 100644 examples/testsets/arc065-c/in/subtask0_0.txt delete mode 100644 examples/testsets/arc065-c/in/subtask0_1.txt delete mode 100644 examples/testsets/arc065-c/in/subtask0_2.txt delete mode 100644 examples/testsets/arc065-c/out/subtask0_0.txt delete mode 100644 examples/testsets/arc065-c/out/subtask0_1.txt delete mode 100644 examples/testsets/arc065-c/out/subtask0_2.txt delete mode 100644 examples/testsets/arc084-c/in/s1.txt delete mode 100644 examples/testsets/arc084-c/in/s2.txt delete mode 100644 examples/testsets/arc084-c/in/s3.txt delete mode 100644 examples/testsets/arc084-c/out/s1.txt delete mode 100644 examples/testsets/arc084-c/out/s2.txt delete mode 100644 examples/testsets/arc084-c/out/s3.txt delete mode 100644 examples/testsets/atc001-b/in/00_sample_01.txt delete mode 100644 examples/testsets/atc001-b/out/00_sample_01.txt delete mode 100644 examples/testsets/atc002-b/in/sample_01.txt delete mode 100644 examples/testsets/atc002-b/in/sample_02.txt delete mode 100644 examples/testsets/atc002-b/out/sample_01.txt delete mode 100644 examples/testsets/atc002-b/out/sample_02.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a5339f..1a5878a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -82,8 +82,8 @@ jobs: command: build args: --all-features --release - - name: '`chmod -R a=rX-w ./target`' - run: chmod -R a=rX-w ./target + - name: '`chmod -R a=rX-w ./target/release`' + run: chmod -R a=rX-w ./target/release - name: '`cargo test-with-generated-opts`' uses: actions-rs/cargo@v1 diff --git a/examples/testsets/abc054-c/in/sample_01.txt b/examples/testsets/abc054-c/in/sample_01.txt deleted file mode 100644 index bc88773..0000000 --- a/examples/testsets/abc054-c/in/sample_01.txt +++ /dev/null @@ -1,4 +0,0 @@ -3 3 -1 2 -1 3 -2 3 diff --git a/examples/testsets/abc054-c/in/sample_02.txt b/examples/testsets/abc054-c/in/sample_02.txt deleted file mode 100644 index 052f07a..0000000 --- a/examples/testsets/abc054-c/in/sample_02.txt +++ /dev/null @@ -1,8 +0,0 @@ -7 7 -1 3 -2 7 -3 4 -4 5 -4 6 -5 6 -6 7 diff --git a/examples/testsets/abc054-c/out/sample_01.txt b/examples/testsets/abc054-c/out/sample_01.txt deleted file mode 100644 index 0cfbf08..0000000 --- a/examples/testsets/abc054-c/out/sample_01.txt +++ /dev/null @@ -1 +0,0 @@ -2 diff --git a/examples/testsets/abc054-c/out/sample_02.txt b/examples/testsets/abc054-c/out/sample_02.txt deleted file mode 100644 index d00491f..0000000 --- a/examples/testsets/abc054-c/out/sample_02.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/examples/testsets/abc057-b/in/sample_01.txt b/examples/testsets/abc057-b/in/sample_01.txt deleted file mode 100644 index c43659a..0000000 --- a/examples/testsets/abc057-b/in/sample_01.txt +++ /dev/null @@ -1,5 +0,0 @@ -2 2 -2 0 -0 0 --1 0 -1 0 diff --git a/examples/testsets/abc057-b/in/sample_02.txt b/examples/testsets/abc057-b/in/sample_02.txt deleted file mode 100644 index 541f6dd..0000000 --- a/examples/testsets/abc057-b/in/sample_02.txt +++ /dev/null @@ -1,8 +0,0 @@ -3 4 -10 10 --10 -10 -3 3 -1 2 -2 3 -3 5 -3 5 diff --git a/examples/testsets/abc057-b/in/sample_03.txt b/examples/testsets/abc057-b/in/sample_03.txt deleted file mode 100644 index 596121c..0000000 --- a/examples/testsets/abc057-b/in/sample_03.txt +++ /dev/null @@ -1,11 +0,0 @@ -5 5 --100000000 -100000000 --100000000 100000000 -100000000 -100000000 -100000000 100000000 -0 0 -0 0 -100000000 100000000 -100000000 -100000000 --100000000 100000000 --100000000 -100000000 diff --git a/examples/testsets/abc057-b/out/sample_01.txt b/examples/testsets/abc057-b/out/sample_01.txt deleted file mode 100644 index 5f1d0ec..0000000 --- a/examples/testsets/abc057-b/out/sample_01.txt +++ /dev/null @@ -1,2 +0,0 @@ -2 -1 diff --git a/examples/testsets/abc057-b/out/sample_02.txt b/examples/testsets/abc057-b/out/sample_02.txt deleted file mode 100644 index 0571a2e..0000000 --- a/examples/testsets/abc057-b/out/sample_02.txt +++ /dev/null @@ -1,3 +0,0 @@ -3 -1 -2 diff --git a/examples/testsets/abc057-b/out/sample_03.txt b/examples/testsets/abc057-b/out/sample_03.txt deleted file mode 100644 index 86e24d1..0000000 --- a/examples/testsets/abc057-b/out/sample_03.txt +++ /dev/null @@ -1,5 +0,0 @@ -5 -4 -3 -2 -1 diff --git a/examples/testsets/abc084-d/in/sample_01.txt b/examples/testsets/abc084-d/in/sample_01.txt deleted file mode 100644 index 6990404..0000000 --- a/examples/testsets/abc084-d/in/sample_01.txt +++ /dev/null @@ -1,2 +0,0 @@ -1 -3 7 diff --git a/examples/testsets/abc084-d/in/sample_02.txt b/examples/testsets/abc084-d/in/sample_02.txt deleted file mode 100644 index 988378b..0000000 --- a/examples/testsets/abc084-d/in/sample_02.txt +++ /dev/null @@ -1,5 +0,0 @@ -4 -13 13 -7 11 -7 11 -2017 2017 diff --git a/examples/testsets/abc084-d/in/sample_03.txt b/examples/testsets/abc084-d/in/sample_03.txt deleted file mode 100644 index da66f27..0000000 --- a/examples/testsets/abc084-d/in/sample_03.txt +++ /dev/null @@ -1,7 +0,0 @@ -6 -1 53 -13 91 -37 55 -19 51 -73 91 -13 49 diff --git a/examples/testsets/abc084-d/out/sample_01.txt b/examples/testsets/abc084-d/out/sample_01.txt deleted file mode 100644 index 0cfbf08..0000000 --- a/examples/testsets/abc084-d/out/sample_01.txt +++ /dev/null @@ -1 +0,0 @@ -2 diff --git a/examples/testsets/abc084-d/out/sample_02.txt b/examples/testsets/abc084-d/out/sample_02.txt deleted file mode 100644 index 680eb50..0000000 --- a/examples/testsets/abc084-d/out/sample_02.txt +++ /dev/null @@ -1,4 +0,0 @@ -1 -0 -0 -1 diff --git a/examples/testsets/abc084-d/out/sample_03.txt b/examples/testsets/abc084-d/out/sample_03.txt deleted file mode 100644 index 10cd9ca..0000000 --- a/examples/testsets/abc084-d/out/sample_03.txt +++ /dev/null @@ -1,6 +0,0 @@ -4 -4 -1 -1 -1 -2 diff --git a/examples/testsets/abc118-b/in/sample_01.txt b/examples/testsets/abc118-b/in/sample_01.txt deleted file mode 100644 index b6505e4..0000000 --- a/examples/testsets/abc118-b/in/sample_01.txt +++ /dev/null @@ -1,4 +0,0 @@ -3 4 -2 1 3 -3 1 2 3 -2 3 2 diff --git a/examples/testsets/abc118-b/in/sample_02.txt b/examples/testsets/abc118-b/in/sample_02.txt deleted file mode 100644 index 993996b..0000000 --- a/examples/testsets/abc118-b/in/sample_02.txt +++ /dev/null @@ -1,6 +0,0 @@ -5 5 -4 2 3 4 5 -4 1 3 4 5 -4 1 2 4 5 -4 1 2 3 5 -4 1 2 3 4 diff --git a/examples/testsets/abc118-b/in/sample_03.txt b/examples/testsets/abc118-b/in/sample_03.txt deleted file mode 100644 index 9e096c0..0000000 --- a/examples/testsets/abc118-b/in/sample_03.txt +++ /dev/null @@ -1,2 +0,0 @@ -1 30 -3 5 10 30 diff --git a/examples/testsets/abc118-b/out/sample_01.txt b/examples/testsets/abc118-b/out/sample_01.txt deleted file mode 100644 index d00491f..0000000 --- a/examples/testsets/abc118-b/out/sample_01.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/examples/testsets/abc118-b/out/sample_02.txt b/examples/testsets/abc118-b/out/sample_02.txt deleted file mode 100644 index 573541a..0000000 --- a/examples/testsets/abc118-b/out/sample_02.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/examples/testsets/abc118-b/out/sample_03.txt b/examples/testsets/abc118-b/out/sample_03.txt deleted file mode 100644 index 00750ed..0000000 --- a/examples/testsets/abc118-b/out/sample_03.txt +++ /dev/null @@ -1 +0,0 @@ -3 diff --git a/examples/testsets/abc120-d/in/sample_01.txt b/examples/testsets/abc120-d/in/sample_01.txt deleted file mode 100644 index 8881ee2..0000000 --- a/examples/testsets/abc120-d/in/sample_01.txt +++ /dev/null @@ -1,6 +0,0 @@ -4 5 -1 2 -3 4 -1 3 -2 3 -1 4 diff --git a/examples/testsets/abc120-d/in/sample_02.txt b/examples/testsets/abc120-d/in/sample_02.txt deleted file mode 100644 index 23a7d58..0000000 --- a/examples/testsets/abc120-d/in/sample_02.txt +++ /dev/null @@ -1,6 +0,0 @@ -6 5 -2 3 -1 2 -5 6 -3 4 -4 5 diff --git a/examples/testsets/abc120-d/in/sample_03.txt b/examples/testsets/abc120-d/in/sample_03.txt deleted file mode 100644 index c9fa102..0000000 --- a/examples/testsets/abc120-d/in/sample_03.txt +++ /dev/null @@ -1,2 +0,0 @@ -2 1 -1 2 diff --git a/examples/testsets/abc120-d/out/sample_01.txt b/examples/testsets/abc120-d/out/sample_01.txt deleted file mode 100644 index ce56183..0000000 --- a/examples/testsets/abc120-d/out/sample_01.txt +++ /dev/null @@ -1,5 +0,0 @@ -0 -0 -4 -5 -6 diff --git a/examples/testsets/abc120-d/out/sample_02.txt b/examples/testsets/abc120-d/out/sample_02.txt deleted file mode 100644 index 83dd8d4..0000000 --- a/examples/testsets/abc120-d/out/sample_02.txt +++ /dev/null @@ -1,5 +0,0 @@ -8 -9 -12 -14 -15 diff --git a/examples/testsets/abc120-d/out/sample_03.txt b/examples/testsets/abc120-d/out/sample_03.txt deleted file mode 100644 index d00491f..0000000 --- a/examples/testsets/abc120-d/out/sample_03.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/examples/testsets/abc121-b/in/sample_01.txt b/examples/testsets/abc121-b/in/sample_01.txt deleted file mode 100644 index 27c8ec2..0000000 --- a/examples/testsets/abc121-b/in/sample_01.txt +++ /dev/null @@ -1,4 +0,0 @@ -2 3 -10 -1 2 3 -3 2 1 -1 2 2 diff --git a/examples/testsets/abc121-b/in/sample_02.txt b/examples/testsets/abc121-b/in/sample_02.txt deleted file mode 100644 index b47a11c..0000000 --- a/examples/testsets/abc121-b/in/sample_02.txt +++ /dev/null @@ -1,7 +0,0 @@ -5 2 -4 --2 5 -100 41 -100 40 --3 0 --6 -2 -18 -13 diff --git a/examples/testsets/abc121-b/in/sample_03.txt b/examples/testsets/abc121-b/in/sample_03.txt deleted file mode 100644 index 819f8c3..0000000 --- a/examples/testsets/abc121-b/in/sample_03.txt +++ /dev/null @@ -1,5 +0,0 @@ -3 3 0 -100 -100 0 -0 100 100 -100 100 100 --100 100 100 diff --git a/examples/testsets/abc121-b/out/sample_01.txt b/examples/testsets/abc121-b/out/sample_01.txt deleted file mode 100644 index d00491f..0000000 --- a/examples/testsets/abc121-b/out/sample_01.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/examples/testsets/abc121-b/out/sample_02.txt b/examples/testsets/abc121-b/out/sample_02.txt deleted file mode 100644 index 0cfbf08..0000000 --- a/examples/testsets/abc121-b/out/sample_02.txt +++ /dev/null @@ -1 +0,0 @@ -2 diff --git a/examples/testsets/abc121-b/out/sample_03.txt b/examples/testsets/abc121-b/out/sample_03.txt deleted file mode 100644 index 573541a..0000000 --- a/examples/testsets/abc121-b/out/sample_03.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/examples/testsets/abc129-f/in/sample_01.txt b/examples/testsets/abc129-f/in/sample_01.txt deleted file mode 100644 index 42e1211..0000000 --- a/examples/testsets/abc129-f/in/sample_01.txt +++ /dev/null @@ -1 +0,0 @@ -5 3 4 10007 diff --git a/examples/testsets/abc129-f/in/sample_02.txt b/examples/testsets/abc129-f/in/sample_02.txt deleted file mode 100644 index 969f9fc..0000000 --- a/examples/testsets/abc129-f/in/sample_02.txt +++ /dev/null @@ -1 +0,0 @@ -4 8 1 1000000 diff --git a/examples/testsets/abc129-f/in/sample_03.txt b/examples/testsets/abc129-f/in/sample_03.txt deleted file mode 100644 index 7cb7ba4..0000000 --- a/examples/testsets/abc129-f/in/sample_03.txt +++ /dev/null @@ -1 +0,0 @@ -107 10000000000007 1000000000000007 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_killer_01.txt b/examples/testsets/abc129-f/in/sub1_killer_01.txt deleted file mode 100644 index cb59cb9..0000000 --- a/examples/testsets/abc129-f/in/sub1_killer_01.txt +++ /dev/null @@ -1 +0,0 @@ -2500000000000 4 4 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_killer_02.txt b/examples/testsets/abc129-f/in/sub1_killer_02.txt deleted file mode 100644 index b1582fc..0000000 --- a/examples/testsets/abc129-f/in/sub1_killer_02.txt +++ /dev/null @@ -1 +0,0 @@ -99982444353 100 4 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_killer_03.txt b/examples/testsets/abc129-f/in/sub1_killer_03.txt deleted file mode 100644 index 8067387..0000000 --- a/examples/testsets/abc129-f/in/sub1_killer_03.txt +++ /dev/null @@ -1 +0,0 @@ -333333333333333333 3 3 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_killer_04.txt b/examples/testsets/abc129-f/in/sub1_killer_04.txt deleted file mode 100644 index caf49ce..0000000 --- a/examples/testsets/abc129-f/in/sub1_killer_04.txt +++ /dev/null @@ -1 +0,0 @@ -1 999999999999999999 999999999999999999 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_killer_05.txt b/examples/testsets/abc129-f/in/sub1_killer_05.txt deleted file mode 100644 index 8dad240..0000000 --- a/examples/testsets/abc129-f/in/sub1_killer_05.txt +++ /dev/null @@ -1 +0,0 @@ -998244353 629149506971940504 319836804 14876851 diff --git a/examples/testsets/abc129-f/in/sub1_killer_06.txt b/examples/testsets/abc129-f/in/sub1_killer_06.txt deleted file mode 100644 index ee45d99..0000000 --- a/examples/testsets/abc129-f/in/sub1_killer_06.txt +++ /dev/null @@ -1 +0,0 @@ -999918203 4248 723308865 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_killer_07.txt b/examples/testsets/abc129-f/in/sub1_killer_07.txt deleted file mode 100644 index 7c691d6..0000000 --- a/examples/testsets/abc129-f/in/sub1_killer_07.txt +++ /dev/null @@ -1 +0,0 @@ -100000000000 6 231 25200 diff --git a/examples/testsets/abc129-f/in/sub1_large_01.txt b/examples/testsets/abc129-f/in/sub1_large_01.txt deleted file mode 100644 index 1bf1e1b..0000000 --- a/examples/testsets/abc129-f/in/sub1_large_01.txt +++ /dev/null @@ -1 +0,0 @@ -999999999999999999 1 1 1000000000 diff --git a/examples/testsets/abc129-f/in/sub1_large_02.txt b/examples/testsets/abc129-f/in/sub1_large_02.txt deleted file mode 100644 index 09de7a1..0000000 --- a/examples/testsets/abc129-f/in/sub1_large_02.txt +++ /dev/null @@ -1 +0,0 @@ -11837588 221218607 84473754642 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_large_03.txt b/examples/testsets/abc129-f/in/sub1_large_03.txt deleted file mode 100644 index 9d8ee74..0000000 --- a/examples/testsets/abc129-f/in/sub1_large_03.txt +++ /dev/null @@ -1 +0,0 @@ -81074056293 7047569542 12261087 29999997 diff --git a/examples/testsets/abc129-f/in/sub1_large_04.txt b/examples/testsets/abc129-f/in/sub1_large_04.txt deleted file mode 100644 index b484c04..0000000 --- a/examples/testsets/abc129-f/in/sub1_large_04.txt +++ /dev/null @@ -1 +0,0 @@ -999999999999999999 1 1 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_large_05.txt b/examples/testsets/abc129-f/in/sub1_large_05.txt deleted file mode 100644 index 98320ad..0000000 --- a/examples/testsets/abc129-f/in/sub1_large_05.txt +++ /dev/null @@ -1 +0,0 @@ -328613923524538 40980 3031 999999999 diff --git a/examples/testsets/abc129-f/in/sub1_large_06.txt b/examples/testsets/abc129-f/in/sub1_large_06.txt deleted file mode 100644 index 111af0c..0000000 --- a/examples/testsets/abc129-f/in/sub1_large_06.txt +++ /dev/null @@ -1 +0,0 @@ -10914883567412 1570 62840 99999999 diff --git a/examples/testsets/abc129-f/in/sub1_large_07.txt b/examples/testsets/abc129-f/in/sub1_large_07.txt deleted file mode 100644 index 502b824..0000000 --- a/examples/testsets/abc129-f/in/sub1_large_07.txt +++ /dev/null @@ -1 +0,0 @@ -1448057007031098 11 690 881005587 diff --git a/examples/testsets/abc129-f/in/sub1_large_08.txt b/examples/testsets/abc129-f/in/sub1_large_08.txt deleted file mode 100644 index e3210cc..0000000 --- a/examples/testsets/abc129-f/in/sub1_large_08.txt +++ /dev/null @@ -1 +0,0 @@ -74358445905354 29310 13448 147413419 diff --git a/examples/testsets/abc129-f/in/sub1_large_09.txt b/examples/testsets/abc129-f/in/sub1_large_09.txt deleted file mode 100644 index 953a3a1..0000000 --- a/examples/testsets/abc129-f/in/sub1_large_09.txt +++ /dev/null @@ -1 +0,0 @@ -120900801167206 994 8061 387420489 diff --git a/examples/testsets/abc129-f/in/sub1_rand_01.txt b/examples/testsets/abc129-f/in/sub1_rand_01.txt deleted file mode 100644 index bf29c51..0000000 --- a/examples/testsets/abc129-f/in/sub1_rand_01.txt +++ /dev/null @@ -1 +0,0 @@ -1380800559 8 721124722 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_rand_02.txt b/examples/testsets/abc129-f/in/sub1_rand_02.txt deleted file mode 100644 index ce81814..0000000 --- a/examples/testsets/abc129-f/in/sub1_rand_02.txt +++ /dev/null @@ -1 +0,0 @@ -105301221317 8 9457145 999999999 diff --git a/examples/testsets/abc129-f/in/sub1_rand_03.txt b/examples/testsets/abc129-f/in/sub1_rand_03.txt deleted file mode 100644 index a115e1e..0000000 --- a/examples/testsets/abc129-f/in/sub1_rand_03.txt +++ /dev/null @@ -1 +0,0 @@ -53562851 12672052437647 18553359394 99999999 diff --git a/examples/testsets/abc129-f/in/sub1_rand_04.txt b/examples/testsets/abc129-f/in/sub1_rand_04.txt deleted file mode 100644 index 74d7f96..0000000 --- a/examples/testsets/abc129-f/in/sub1_rand_04.txt +++ /dev/null @@ -1 +0,0 @@ -7343 44375369427231 136194167038156 841293953 diff --git a/examples/testsets/abc129-f/in/sub1_rand_05.txt b/examples/testsets/abc129-f/in/sub1_rand_05.txt deleted file mode 100644 index ec7780e..0000000 --- a/examples/testsets/abc129-f/in/sub1_rand_05.txt +++ /dev/null @@ -1 +0,0 @@ -234481 8715183188079 4262710627175 9999999 diff --git a/examples/testsets/abc129-f/in/sub1_rand_06.txt b/examples/testsets/abc129-f/in/sub1_rand_06.txt deleted file mode 100644 index 96df56c..0000000 --- a/examples/testsets/abc129-f/in/sub1_rand_06.txt +++ /dev/null @@ -1 +0,0 @@ -335 2647488178484 2976541338296614 999918169 diff --git a/examples/testsets/abc129-f/in/sub1_rand_07.txt b/examples/testsets/abc129-f/in/sub1_rand_07.txt deleted file mode 100644 index c352840..0000000 --- a/examples/testsets/abc129-f/in/sub1_rand_07.txt +++ /dev/null @@ -1 +0,0 @@ -2508131942730888 5 397 387420489 diff --git a/examples/testsets/abc129-f/in/sub1_rand_08.txt b/examples/testsets/abc129-f/in/sub1_rand_08.txt deleted file mode 100644 index f2eebd5..0000000 --- a/examples/testsets/abc129-f/in/sub1_rand_08.txt +++ /dev/null @@ -1 +0,0 @@ -151407055 44693807224027 6603923461 1000000000 diff --git a/examples/testsets/abc129-f/in/sub1_rand_09.txt b/examples/testsets/abc129-f/in/sub1_rand_09.txt deleted file mode 100644 index baf9c53..0000000 --- a/examples/testsets/abc129-f/in/sub1_rand_09.txt +++ /dev/null @@ -1 +0,0 @@ -17544042820 3 56987735 387420489 diff --git a/examples/testsets/abc129-f/in/sub1_rand_10.txt b/examples/testsets/abc129-f/in/sub1_rand_10.txt deleted file mode 100644 index ba0c84d..0000000 --- a/examples/testsets/abc129-f/in/sub1_rand_10.txt +++ /dev/null @@ -1 +0,0 @@ -355391 6022223566881 25138147452 999958020 diff --git a/examples/testsets/abc129-f/in/sub1_small_01.txt b/examples/testsets/abc129-f/in/sub1_small_01.txt deleted file mode 100644 index 4cddd91..0000000 --- a/examples/testsets/abc129-f/in/sub1_small_01.txt +++ /dev/null @@ -1 +0,0 @@ -18 912087068546306627 3164574410046630 996674566 diff --git a/examples/testsets/abc129-f/in/sub1_small_02.txt b/examples/testsets/abc129-f/in/sub1_small_02.txt deleted file mode 100644 index 00b538c..0000000 --- a/examples/testsets/abc129-f/in/sub1_small_02.txt +++ /dev/null @@ -1 +0,0 @@ -31940 139378099479290043 26943708742238 1000000000 diff --git a/examples/testsets/abc129-f/in/sub1_small_03.txt b/examples/testsets/abc129-f/in/sub1_small_03.txt deleted file mode 100644 index 133c54d..0000000 --- a/examples/testsets/abc129-f/in/sub1_small_03.txt +++ /dev/null @@ -1 +0,0 @@ -345 493299812499659259 1418510335032035 998244353 diff --git a/examples/testsets/abc129-f/in/sub1_small_04.txt b/examples/testsets/abc129-f/in/sub1_small_04.txt deleted file mode 100644 index 6daed7f..0000000 --- a/examples/testsets/abc129-f/in/sub1_small_04.txt +++ /dev/null @@ -1 +0,0 @@ -3776 494095262613235502 19199433662734 999999 diff --git a/examples/testsets/abc129-f/in/sub1_small_05.txt b/examples/testsets/abc129-f/in/sub1_small_05.txt deleted file mode 100644 index 3b1845d..0000000 --- a/examples/testsets/abc129-f/in/sub1_small_05.txt +++ /dev/null @@ -1 +0,0 @@ -461491 67429808854595636 2017247872269 276712227 diff --git a/examples/testsets/abc129-f/in/sub1_small_06.txt b/examples/testsets/abc129-f/in/sub1_small_06.txt deleted file mode 100644 index f52b3dd..0000000 --- a/examples/testsets/abc129-f/in/sub1_small_06.txt +++ /dev/null @@ -1 +0,0 @@ -147 4222724580641548 6588820255446743 982883281 diff --git a/examples/testsets/abc129-f/out/sample_01.txt b/examples/testsets/abc129-f/out/sample_01.txt deleted file mode 100644 index f3e5209..0000000 --- a/examples/testsets/abc129-f/out/sample_01.txt +++ /dev/null @@ -1 +0,0 @@ -5563 diff --git a/examples/testsets/abc129-f/out/sample_02.txt b/examples/testsets/abc129-f/out/sample_02.txt deleted file mode 100644 index ebe706b..0000000 --- a/examples/testsets/abc129-f/out/sample_02.txt +++ /dev/null @@ -1 +0,0 @@ -891011 diff --git a/examples/testsets/abc129-f/out/sample_03.txt b/examples/testsets/abc129-f/out/sample_03.txt deleted file mode 100644 index d7e18ae..0000000 --- a/examples/testsets/abc129-f/out/sample_03.txt +++ /dev/null @@ -1 +0,0 @@ -39122908 diff --git a/examples/testsets/abc129-f/out/sub1_killer_01.txt b/examples/testsets/abc129-f/out/sub1_killer_01.txt deleted file mode 100644 index 10b65f2..0000000 --- a/examples/testsets/abc129-f/out/sub1_killer_01.txt +++ /dev/null @@ -1 +0,0 @@ -900161126 diff --git a/examples/testsets/abc129-f/out/sub1_killer_02.txt b/examples/testsets/abc129-f/out/sub1_killer_02.txt deleted file mode 100644 index a851e0c..0000000 --- a/examples/testsets/abc129-f/out/sub1_killer_02.txt +++ /dev/null @@ -1 +0,0 @@ -658481246 diff --git a/examples/testsets/abc129-f/out/sub1_killer_03.txt b/examples/testsets/abc129-f/out/sub1_killer_03.txt deleted file mode 100644 index 43cff07..0000000 --- a/examples/testsets/abc129-f/out/sub1_killer_03.txt +++ /dev/null @@ -1 +0,0 @@ -521296277 diff --git a/examples/testsets/abc129-f/out/sub1_killer_04.txt b/examples/testsets/abc129-f/out/sub1_killer_04.txt deleted file mode 100644 index 1c41192..0000000 --- a/examples/testsets/abc129-f/out/sub1_killer_04.txt +++ /dev/null @@ -1 +0,0 @@ -716070897 diff --git a/examples/testsets/abc129-f/out/sub1_killer_05.txt b/examples/testsets/abc129-f/out/sub1_killer_05.txt deleted file mode 100644 index f8a402d..0000000 --- a/examples/testsets/abc129-f/out/sub1_killer_05.txt +++ /dev/null @@ -1 +0,0 @@ -9086340 diff --git a/examples/testsets/abc129-f/out/sub1_killer_06.txt b/examples/testsets/abc129-f/out/sub1_killer_06.txt deleted file mode 100644 index 2e84594..0000000 --- a/examples/testsets/abc129-f/out/sub1_killer_06.txt +++ /dev/null @@ -1 +0,0 @@ -822961451 diff --git a/examples/testsets/abc129-f/out/sub1_killer_07.txt b/examples/testsets/abc129-f/out/sub1_killer_07.txt deleted file mode 100644 index 56b4803..0000000 --- a/examples/testsets/abc129-f/out/sub1_killer_07.txt +++ /dev/null @@ -1 +0,0 @@ -12975 diff --git a/examples/testsets/abc129-f/out/sub1_large_01.txt b/examples/testsets/abc129-f/out/sub1_large_01.txt deleted file mode 100644 index 28e56d9..0000000 --- a/examples/testsets/abc129-f/out/sub1_large_01.txt +++ /dev/null @@ -1 +0,0 @@ -999999999 diff --git a/examples/testsets/abc129-f/out/sub1_large_02.txt b/examples/testsets/abc129-f/out/sub1_large_02.txt deleted file mode 100644 index 7a2f4fe..0000000 --- a/examples/testsets/abc129-f/out/sub1_large_02.txt +++ /dev/null @@ -1 +0,0 @@ -739823859 diff --git a/examples/testsets/abc129-f/out/sub1_large_03.txt b/examples/testsets/abc129-f/out/sub1_large_03.txt deleted file mode 100644 index 6f3846a..0000000 --- a/examples/testsets/abc129-f/out/sub1_large_03.txt +++ /dev/null @@ -1 +0,0 @@ -7215183 diff --git a/examples/testsets/abc129-f/out/sub1_large_04.txt b/examples/testsets/abc129-f/out/sub1_large_04.txt deleted file mode 100644 index 7d3d74f..0000000 --- a/examples/testsets/abc129-f/out/sub1_large_04.txt +++ /dev/null @@ -1 +0,0 @@ -795127085 diff --git a/examples/testsets/abc129-f/out/sub1_large_05.txt b/examples/testsets/abc129-f/out/sub1_large_05.txt deleted file mode 100644 index ad676a4..0000000 --- a/examples/testsets/abc129-f/out/sub1_large_05.txt +++ /dev/null @@ -1 +0,0 @@ -222138048 diff --git a/examples/testsets/abc129-f/out/sub1_large_06.txt b/examples/testsets/abc129-f/out/sub1_large_06.txt deleted file mode 100644 index a6bb95b..0000000 --- a/examples/testsets/abc129-f/out/sub1_large_06.txt +++ /dev/null @@ -1 +0,0 @@ -96844045 diff --git a/examples/testsets/abc129-f/out/sub1_large_07.txt b/examples/testsets/abc129-f/out/sub1_large_07.txt deleted file mode 100644 index 4f87764..0000000 --- a/examples/testsets/abc129-f/out/sub1_large_07.txt +++ /dev/null @@ -1 +0,0 @@ -257000862 diff --git a/examples/testsets/abc129-f/out/sub1_large_08.txt b/examples/testsets/abc129-f/out/sub1_large_08.txt deleted file mode 100644 index 5c43ef6..0000000 --- a/examples/testsets/abc129-f/out/sub1_large_08.txt +++ /dev/null @@ -1 +0,0 @@ -55813670 diff --git a/examples/testsets/abc129-f/out/sub1_large_09.txt b/examples/testsets/abc129-f/out/sub1_large_09.txt deleted file mode 100644 index a714ffb..0000000 --- a/examples/testsets/abc129-f/out/sub1_large_09.txt +++ /dev/null @@ -1 +0,0 @@ -109152748 diff --git a/examples/testsets/abc129-f/out/sub1_rand_01.txt b/examples/testsets/abc129-f/out/sub1_rand_01.txt deleted file mode 100644 index 47237fc..0000000 --- a/examples/testsets/abc129-f/out/sub1_rand_01.txt +++ /dev/null @@ -1 +0,0 @@ -932512687 diff --git a/examples/testsets/abc129-f/out/sub1_rand_02.txt b/examples/testsets/abc129-f/out/sub1_rand_02.txt deleted file mode 100644 index 3569ef6..0000000 --- a/examples/testsets/abc129-f/out/sub1_rand_02.txt +++ /dev/null @@ -1 +0,0 @@ -976788549 diff --git a/examples/testsets/abc129-f/out/sub1_rand_03.txt b/examples/testsets/abc129-f/out/sub1_rand_03.txt deleted file mode 100644 index 446994c..0000000 --- a/examples/testsets/abc129-f/out/sub1_rand_03.txt +++ /dev/null @@ -1 +0,0 @@ -84300371 diff --git a/examples/testsets/abc129-f/out/sub1_rand_04.txt b/examples/testsets/abc129-f/out/sub1_rand_04.txt deleted file mode 100644 index 930a068..0000000 --- a/examples/testsets/abc129-f/out/sub1_rand_04.txt +++ /dev/null @@ -1 +0,0 @@ -336830166 diff --git a/examples/testsets/abc129-f/out/sub1_rand_05.txt b/examples/testsets/abc129-f/out/sub1_rand_05.txt deleted file mode 100644 index f98cf2c..0000000 --- a/examples/testsets/abc129-f/out/sub1_rand_05.txt +++ /dev/null @@ -1 +0,0 @@ -699837 diff --git a/examples/testsets/abc129-f/out/sub1_rand_06.txt b/examples/testsets/abc129-f/out/sub1_rand_06.txt deleted file mode 100644 index 123565f..0000000 --- a/examples/testsets/abc129-f/out/sub1_rand_06.txt +++ /dev/null @@ -1 +0,0 @@ -184277614 diff --git a/examples/testsets/abc129-f/out/sub1_rand_07.txt b/examples/testsets/abc129-f/out/sub1_rand_07.txt deleted file mode 100644 index 7fe4b6d..0000000 --- a/examples/testsets/abc129-f/out/sub1_rand_07.txt +++ /dev/null @@ -1 +0,0 @@ -357790932 diff --git a/examples/testsets/abc129-f/out/sub1_rand_08.txt b/examples/testsets/abc129-f/out/sub1_rand_08.txt deleted file mode 100644 index 7f65140..0000000 --- a/examples/testsets/abc129-f/out/sub1_rand_08.txt +++ /dev/null @@ -1 +0,0 @@ -878717921 diff --git a/examples/testsets/abc129-f/out/sub1_rand_09.txt b/examples/testsets/abc129-f/out/sub1_rand_09.txt deleted file mode 100644 index 38ba959..0000000 --- a/examples/testsets/abc129-f/out/sub1_rand_09.txt +++ /dev/null @@ -1 +0,0 @@ -207193062 diff --git a/examples/testsets/abc129-f/out/sub1_rand_10.txt b/examples/testsets/abc129-f/out/sub1_rand_10.txt deleted file mode 100644 index 8773a4d..0000000 --- a/examples/testsets/abc129-f/out/sub1_rand_10.txt +++ /dev/null @@ -1 +0,0 @@ -336284961 diff --git a/examples/testsets/abc129-f/out/sub1_small_01.txt b/examples/testsets/abc129-f/out/sub1_small_01.txt deleted file mode 100644 index 9906162..0000000 --- a/examples/testsets/abc129-f/out/sub1_small_01.txt +++ /dev/null @@ -1 +0,0 @@ -564963471 diff --git a/examples/testsets/abc129-f/out/sub1_small_02.txt b/examples/testsets/abc129-f/out/sub1_small_02.txt deleted file mode 100644 index 8242c5e..0000000 --- a/examples/testsets/abc129-f/out/sub1_small_02.txt +++ /dev/null @@ -1 +0,0 @@ -997629525 diff --git a/examples/testsets/abc129-f/out/sub1_small_03.txt b/examples/testsets/abc129-f/out/sub1_small_03.txt deleted file mode 100644 index d0ba21a..0000000 --- a/examples/testsets/abc129-f/out/sub1_small_03.txt +++ /dev/null @@ -1 +0,0 @@ -390889114 diff --git a/examples/testsets/abc129-f/out/sub1_small_04.txt b/examples/testsets/abc129-f/out/sub1_small_04.txt deleted file mode 100644 index 36aaed9..0000000 --- a/examples/testsets/abc129-f/out/sub1_small_04.txt +++ /dev/null @@ -1 +0,0 @@ -792884 diff --git a/examples/testsets/abc129-f/out/sub1_small_05.txt b/examples/testsets/abc129-f/out/sub1_small_05.txt deleted file mode 100644 index 93f44a4..0000000 --- a/examples/testsets/abc129-f/out/sub1_small_05.txt +++ /dev/null @@ -1 +0,0 @@ -203043563 diff --git a/examples/testsets/abc129-f/out/sub1_small_06.txt b/examples/testsets/abc129-f/out/sub1_small_06.txt deleted file mode 100644 index f472c41..0000000 --- a/examples/testsets/abc129-f/out/sub1_small_06.txt +++ /dev/null @@ -1 +0,0 @@ -887967106 diff --git a/examples/testsets/abc142-d/in/sample_01.txt b/examples/testsets/abc142-d/in/sample_01.txt deleted file mode 100644 index f86db24..0000000 --- a/examples/testsets/abc142-d/in/sample_01.txt +++ /dev/null @@ -1 +0,0 @@ -12 18 diff --git a/examples/testsets/abc142-d/in/sample_02.txt b/examples/testsets/abc142-d/in/sample_02.txt deleted file mode 100644 index 2b55e52..0000000 --- a/examples/testsets/abc142-d/in/sample_02.txt +++ /dev/null @@ -1 +0,0 @@ -420 660 diff --git a/examples/testsets/abc142-d/in/sample_03.txt b/examples/testsets/abc142-d/in/sample_03.txt deleted file mode 100644 index 381ada1..0000000 --- a/examples/testsets/abc142-d/in/sample_03.txt +++ /dev/null @@ -1 +0,0 @@ -1 2019 diff --git a/examples/testsets/abc142-d/out/sample_01.txt b/examples/testsets/abc142-d/out/sample_01.txt deleted file mode 100644 index 00750ed..0000000 --- a/examples/testsets/abc142-d/out/sample_01.txt +++ /dev/null @@ -1 +0,0 @@ -3 diff --git a/examples/testsets/abc142-d/out/sample_02.txt b/examples/testsets/abc142-d/out/sample_02.txt deleted file mode 100644 index b8626c4..0000000 --- a/examples/testsets/abc142-d/out/sample_02.txt +++ /dev/null @@ -1 +0,0 @@ -4 diff --git a/examples/testsets/abc142-d/out/sample_03.txt b/examples/testsets/abc142-d/out/sample_03.txt deleted file mode 100644 index d00491f..0000000 --- a/examples/testsets/abc142-d/out/sample_03.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/examples/testsets/abc144-d/in/handmade03.txt b/examples/testsets/abc144-d/in/handmade03.txt deleted file mode 100644 index 8e93976..0000000 --- a/examples/testsets/abc144-d/in/handmade03.txt +++ /dev/null @@ -1 +0,0 @@ -100 100 1000000 diff --git a/examples/testsets/abc144-d/in/handmade04.txt b/examples/testsets/abc144-d/in/handmade04.txt deleted file mode 100644 index 7fbeff6..0000000 --- a/examples/testsets/abc144-d/in/handmade04.txt +++ /dev/null @@ -1 +0,0 @@ -100 100 1 diff --git a/examples/testsets/abc144-d/in/random05.txt b/examples/testsets/abc144-d/in/random05.txt deleted file mode 100644 index 14990bf..0000000 --- a/examples/testsets/abc144-d/in/random05.txt +++ /dev/null @@ -1 +0,0 @@ -22 75 24126 diff --git a/examples/testsets/abc144-d/in/random06.txt b/examples/testsets/abc144-d/in/random06.txt deleted file mode 100644 index 755b7bf..0000000 --- a/examples/testsets/abc144-d/in/random06.txt +++ /dev/null @@ -1 +0,0 @@ -45 72 83481 diff --git a/examples/testsets/abc144-d/in/random07.txt b/examples/testsets/abc144-d/in/random07.txt deleted file mode 100644 index 39779cd..0000000 --- a/examples/testsets/abc144-d/in/random07.txt +++ /dev/null @@ -1 +0,0 @@ -47 29 44734 diff --git a/examples/testsets/abc144-d/in/random08.txt b/examples/testsets/abc144-d/in/random08.txt deleted file mode 100644 index 3879741..0000000 --- a/examples/testsets/abc144-d/in/random08.txt +++ /dev/null @@ -1 +0,0 @@ -2 75 25 diff --git a/examples/testsets/abc144-d/in/random09.txt b/examples/testsets/abc144-d/in/random09.txt deleted file mode 100644 index 743d648..0000000 --- a/examples/testsets/abc144-d/in/random09.txt +++ /dev/null @@ -1 +0,0 @@ -82 84 416241 diff --git a/examples/testsets/abc144-d/in/random10.txt b/examples/testsets/abc144-d/in/random10.txt deleted file mode 100644 index f6ed7a2..0000000 --- a/examples/testsets/abc144-d/in/random10.txt +++ /dev/null @@ -1 +0,0 @@ -56 32 30430 diff --git a/examples/testsets/abc144-d/in/random11.txt b/examples/testsets/abc144-d/in/random11.txt deleted file mode 100644 index a7f6400..0000000 --- a/examples/testsets/abc144-d/in/random11.txt +++ /dev/null @@ -1 +0,0 @@ -28 37 11105 diff --git a/examples/testsets/abc144-d/in/random12.txt b/examples/testsets/abc144-d/in/random12.txt deleted file mode 100644 index 335f3df..0000000 --- a/examples/testsets/abc144-d/in/random12.txt +++ /dev/null @@ -1 +0,0 @@ -39 18 23359 diff --git a/examples/testsets/abc144-d/in/random13.txt b/examples/testsets/abc144-d/in/random13.txt deleted file mode 100644 index 198104c..0000000 --- a/examples/testsets/abc144-d/in/random13.txt +++ /dev/null @@ -1 +0,0 @@ -79 6 29018 diff --git a/examples/testsets/abc144-d/in/random14.txt b/examples/testsets/abc144-d/in/random14.txt deleted file mode 100644 index 69c13fe..0000000 --- a/examples/testsets/abc144-d/in/random14.txt +++ /dev/null @@ -1 +0,0 @@ -68 68 313904 diff --git a/examples/testsets/abc144-d/in/sample00.txt b/examples/testsets/abc144-d/in/sample00.txt deleted file mode 100644 index f50aaec..0000000 --- a/examples/testsets/abc144-d/in/sample00.txt +++ /dev/null @@ -1 +0,0 @@ -2 2 4 diff --git a/examples/testsets/abc144-d/in/sample01.txt b/examples/testsets/abc144-d/in/sample01.txt deleted file mode 100644 index 4fe9466..0000000 --- a/examples/testsets/abc144-d/in/sample01.txt +++ /dev/null @@ -1 +0,0 @@ -12 21 10 diff --git a/examples/testsets/abc144-d/in/sample02.txt b/examples/testsets/abc144-d/in/sample02.txt deleted file mode 100644 index 469cc0f..0000000 --- a/examples/testsets/abc144-d/in/sample02.txt +++ /dev/null @@ -1 +0,0 @@ -3 1 8 diff --git a/examples/testsets/abc144-d/out/handmade03.txt b/examples/testsets/abc144-d/out/handmade03.txt deleted file mode 100644 index c9ea018..0000000 --- a/examples/testsets/abc144-d/out/handmade03.txt +++ /dev/null @@ -1 +0,0 @@ -0.0000000000 diff --git a/examples/testsets/abc144-d/out/handmade04.txt b/examples/testsets/abc144-d/out/handmade04.txt deleted file mode 100644 index 04e6032..0000000 --- a/examples/testsets/abc144-d/out/handmade04.txt +++ /dev/null @@ -1 +0,0 @@ -89.9998854084 diff --git a/examples/testsets/abc144-d/out/random05.txt b/examples/testsets/abc144-d/out/random05.txt deleted file mode 100644 index 360fb06..0000000 --- a/examples/testsets/abc144-d/out/random05.txt +++ /dev/null @@ -1 +0,0 @@ -66.3790171829 diff --git a/examples/testsets/abc144-d/out/random06.txt b/examples/testsets/abc144-d/out/random06.txt deleted file mode 100644 index 4520afe..0000000 --- a/examples/testsets/abc144-d/out/random06.txt +++ /dev/null @@ -1 +0,0 @@ -53.8288157430 diff --git a/examples/testsets/abc144-d/out/random07.txt b/examples/testsets/abc144-d/out/random07.txt deleted file mode 100644 index d696f30..0000000 --- a/examples/testsets/abc144-d/out/random07.txt +++ /dev/null @@ -1 +0,0 @@ -20.4206366709 diff --git a/examples/testsets/abc144-d/out/random08.txt b/examples/testsets/abc144-d/out/random08.txt deleted file mode 100644 index 695b836..0000000 --- a/examples/testsets/abc144-d/out/random08.txt +++ /dev/null @@ -1 +0,0 @@ -89.7453537677 diff --git a/examples/testsets/abc144-d/out/random09.txt b/examples/testsets/abc144-d/out/random09.txt deleted file mode 100644 index 675a819..0000000 --- a/examples/testsets/abc144-d/out/random09.txt +++ /dev/null @@ -1 +0,0 @@ -28.3216596827 diff --git a/examples/testsets/abc144-d/out/random10.txt b/examples/testsets/abc144-d/out/random10.txt deleted file mode 100644 index dad6b80..0000000 --- a/examples/testsets/abc144-d/out/random10.txt +++ /dev/null @@ -1 +0,0 @@ -43.2962287317 diff --git a/examples/testsets/abc144-d/out/random11.txt b/examples/testsets/abc144-d/out/random11.txt deleted file mode 100644 index 5aade64..0000000 --- a/examples/testsets/abc144-d/out/random11.txt +++ /dev/null @@ -1 +0,0 @@ -59.9115059975 diff --git a/examples/testsets/abc144-d/out/random12.txt b/examples/testsets/abc144-d/out/random12.txt deleted file mode 100644 index 7d70f65..0000000 --- a/examples/testsets/abc144-d/out/random12.txt +++ /dev/null @@ -1 +0,0 @@ -7.7168423353 diff --git a/examples/testsets/abc144-d/out/random13.txt b/examples/testsets/abc144-d/out/random13.txt deleted file mode 100644 index 91cc451..0000000 --- a/examples/testsets/abc144-d/out/random13.txt +++ /dev/null @@ -1 +0,0 @@ -1.9580634609 diff --git a/examples/testsets/abc144-d/out/random14.txt b/examples/testsets/abc144-d/out/random14.txt deleted file mode 100644 index 6b0d01f..0000000 --- a/examples/testsets/abc144-d/out/random14.txt +++ /dev/null @@ -1 +0,0 @@ -0.1924235310 diff --git a/examples/testsets/abc144-d/out/sample00.txt b/examples/testsets/abc144-d/out/sample00.txt deleted file mode 100644 index 5d86419..0000000 --- a/examples/testsets/abc144-d/out/sample00.txt +++ /dev/null @@ -1 +0,0 @@ -45.0000000000 diff --git a/examples/testsets/abc144-d/out/sample01.txt b/examples/testsets/abc144-d/out/sample01.txt deleted file mode 100644 index 09c2e94..0000000 --- a/examples/testsets/abc144-d/out/sample01.txt +++ /dev/null @@ -1 +0,0 @@ -89.7834636934 diff --git a/examples/testsets/abc144-d/out/sample02.txt b/examples/testsets/abc144-d/out/sample02.txt deleted file mode 100644 index d3b8514..0000000 --- a/examples/testsets/abc144-d/out/sample02.txt +++ /dev/null @@ -1 +0,0 @@ -4.2363947991 diff --git a/examples/testsets/apg4b-a/in/sample_01.txt b/examples/testsets/apg4b-a/in/sample_01.txt deleted file mode 100644 index e69de29..0000000 diff --git a/examples/testsets/apg4b-a/out/sample_01.txt b/examples/testsets/apg4b-a/out/sample_01.txt deleted file mode 100644 index af5626b..0000000 --- a/examples/testsets/apg4b-a/out/sample_01.txt +++ /dev/null @@ -1 +0,0 @@ -Hello, world! diff --git a/examples/testsets/apg4b-ex25/in/sample_01.txt b/examples/testsets/apg4b-ex25/in/sample_01.txt deleted file mode 100644 index 72d1a5d..0000000 --- a/examples/testsets/apg4b-ex25/in/sample_01.txt +++ /dev/null @@ -1,5 +0,0 @@ -3 -0 1 2 -3 -1 2 3 -intersection diff --git a/examples/testsets/apg4b-ex25/in/sample_02.txt b/examples/testsets/apg4b-ex25/in/sample_02.txt deleted file mode 100644 index 975f08a..0000000 --- a/examples/testsets/apg4b-ex25/in/sample_02.txt +++ /dev/null @@ -1,5 +0,0 @@ -3 -0 1 2 -3 -1 2 3 -union_set diff --git a/examples/testsets/apg4b-ex25/in/sample_03.txt b/examples/testsets/apg4b-ex25/in/sample_03.txt deleted file mode 100644 index cc0e508..0000000 --- a/examples/testsets/apg4b-ex25/in/sample_03.txt +++ /dev/null @@ -1,5 +0,0 @@ -3 -0 1 2 -3 -1 2 3 -symmetric_diff diff --git a/examples/testsets/apg4b-ex25/in/sample_04.txt b/examples/testsets/apg4b-ex25/in/sample_04.txt deleted file mode 100644 index c5ee91b..0000000 --- a/examples/testsets/apg4b-ex25/in/sample_04.txt +++ /dev/null @@ -1,5 +0,0 @@ -3 -0 1 2 -3 -1 2 3 -subtract 2 diff --git a/examples/testsets/apg4b-ex25/in/sample_05.txt b/examples/testsets/apg4b-ex25/in/sample_05.txt deleted file mode 100644 index 354e615..0000000 --- a/examples/testsets/apg4b-ex25/in/sample_05.txt +++ /dev/null @@ -1,5 +0,0 @@ -3 -0 1 49 -3 -1 2 3 -increment diff --git a/examples/testsets/apg4b-ex25/in/sample_06.txt b/examples/testsets/apg4b-ex25/in/sample_06.txt deleted file mode 100644 index 8d4d22c..0000000 --- a/examples/testsets/apg4b-ex25/in/sample_06.txt +++ /dev/null @@ -1,5 +0,0 @@ -3 -0 1 49 -3 -1 2 3 -decrement diff --git a/examples/testsets/apg4b-ex25/out/sample_01.txt b/examples/testsets/apg4b-ex25/out/sample_01.txt deleted file mode 100644 index 8d04f96..0000000 --- a/examples/testsets/apg4b-ex25/out/sample_01.txt +++ /dev/null @@ -1 +0,0 @@ -1 2 diff --git a/examples/testsets/apg4b-ex25/out/sample_02.txt b/examples/testsets/apg4b-ex25/out/sample_02.txt deleted file mode 100644 index fd15fe1..0000000 --- a/examples/testsets/apg4b-ex25/out/sample_02.txt +++ /dev/null @@ -1 +0,0 @@ -0 1 2 3 diff --git a/examples/testsets/apg4b-ex25/out/sample_03.txt b/examples/testsets/apg4b-ex25/out/sample_03.txt deleted file mode 100644 index 65c9b94..0000000 --- a/examples/testsets/apg4b-ex25/out/sample_03.txt +++ /dev/null @@ -1 +0,0 @@ -0 3 diff --git a/examples/testsets/apg4b-ex25/out/sample_04.txt b/examples/testsets/apg4b-ex25/out/sample_04.txt deleted file mode 100644 index 6e8183b..0000000 --- a/examples/testsets/apg4b-ex25/out/sample_04.txt +++ /dev/null @@ -1 +0,0 @@ -0 1 diff --git a/examples/testsets/apg4b-ex25/out/sample_05.txt b/examples/testsets/apg4b-ex25/out/sample_05.txt deleted file mode 100644 index 63fb4bf..0000000 --- a/examples/testsets/apg4b-ex25/out/sample_05.txt +++ /dev/null @@ -1 +0,0 @@ -0 1 2 diff --git a/examples/testsets/apg4b-ex25/out/sample_06.txt b/examples/testsets/apg4b-ex25/out/sample_06.txt deleted file mode 100644 index 03ebe79..0000000 --- a/examples/testsets/apg4b-ex25/out/sample_06.txt +++ /dev/null @@ -1 +0,0 @@ -0 48 49 diff --git a/examples/testsets/apg4b-ex26/in/sample_01.txt b/examples/testsets/apg4b-ex26/in/sample_01.txt deleted file mode 100644 index c73dcea..0000000 --- a/examples/testsets/apg4b-ex26/in/sample_01.txt +++ /dev/null @@ -1,5 +0,0 @@ -4 -int x = 1 + 2 ; -print_int x + 3 ; -vec a = [ 1 , 2 , x ] ; -print_vec a + [ 4 , 5 , 6 ] ; diff --git a/examples/testsets/apg4b-ex26/in/sample_02.txt b/examples/testsets/apg4b-ex26/in/sample_02.txt deleted file mode 100644 index 52f5052..0000000 --- a/examples/testsets/apg4b-ex26/in/sample_02.txt +++ /dev/null @@ -1,3 +0,0 @@ -2 -print_int 1 - 2 ; -print_vec [ 1 , 2 , 3 ] - [ 3 , 2 , 1 ] ; diff --git a/examples/testsets/apg4b-ex26/in/sample_03.txt b/examples/testsets/apg4b-ex26/in/sample_03.txt deleted file mode 100644 index 9698270..0000000 --- a/examples/testsets/apg4b-ex26/in/sample_03.txt +++ /dev/null @@ -1,2 +0,0 @@ -1 -print_int 5 ; diff --git a/examples/testsets/apg4b-ex26/in/sample_04.txt b/examples/testsets/apg4b-ex26/in/sample_04.txt deleted file mode 100644 index 58ee2d6..0000000 --- a/examples/testsets/apg4b-ex26/in/sample_04.txt +++ /dev/null @@ -1,2 +0,0 @@ -1 -print_vec [ 1 , 2 ] ; diff --git a/examples/testsets/apg4b-ex26/in/sample_05.txt b/examples/testsets/apg4b-ex26/in/sample_05.txt deleted file mode 100644 index 0f3f7a4..0000000 --- a/examples/testsets/apg4b-ex26/in/sample_05.txt +++ /dev/null @@ -1,3 +0,0 @@ -2 -int x = 1 ; -print_int x ; diff --git a/examples/testsets/apg4b-ex26/in/sample_06.txt b/examples/testsets/apg4b-ex26/in/sample_06.txt deleted file mode 100644 index bca6173..0000000 --- a/examples/testsets/apg4b-ex26/in/sample_06.txt +++ /dev/null @@ -1,3 +0,0 @@ -2 -vec a = [ 3 , 4 ] ; -print_vec a ; diff --git a/examples/testsets/apg4b-ex26/in/sample_07.txt b/examples/testsets/apg4b-ex26/in/sample_07.txt deleted file mode 100644 index edbcbb1..0000000 --- a/examples/testsets/apg4b-ex26/in/sample_07.txt +++ /dev/null @@ -1,5 +0,0 @@ -4 -int x = 1 ; -int y = 2 ; -int z = 3 ; -print_int x + y + z ; diff --git a/examples/testsets/apg4b-ex26/in/sample_08.txt b/examples/testsets/apg4b-ex26/in/sample_08.txt deleted file mode 100644 index 62b13df..0000000 --- a/examples/testsets/apg4b-ex26/in/sample_08.txt +++ /dev/null @@ -1,5 +0,0 @@ -4 -vec a = [ 1 , 2 , 3 ] ; -vec b = [ 4 , 5 , 6 ] ; -vec c = [ 7 , 8 , 9 ] ; -print_vec a + b + c ; diff --git a/examples/testsets/apg4b-ex26/in/sample_09.txt b/examples/testsets/apg4b-ex26/in/sample_09.txt deleted file mode 100644 index ba24ea5..0000000 --- a/examples/testsets/apg4b-ex26/in/sample_09.txt +++ /dev/null @@ -1,7 +0,0 @@ -6 -vec a = [ 1 , 2 ] ; -vec b = a + [ 3 , 4 ] ; -vec c = a - [ 5 , 6 ] ; -print_vec a ; -print_vec b ; -print_vec c ; diff --git a/examples/testsets/apg4b-ex26/out/sample_01.txt b/examples/testsets/apg4b-ex26/out/sample_01.txt deleted file mode 100644 index e21af7e..0000000 --- a/examples/testsets/apg4b-ex26/out/sample_01.txt +++ /dev/null @@ -1,2 +0,0 @@ -6 -[ 5 7 9 ] diff --git a/examples/testsets/apg4b-ex26/out/sample_02.txt b/examples/testsets/apg4b-ex26/out/sample_02.txt deleted file mode 100644 index 22e4cf0..0000000 --- a/examples/testsets/apg4b-ex26/out/sample_02.txt +++ /dev/null @@ -1,2 +0,0 @@ --1 -[ -2 0 2 ] diff --git a/examples/testsets/apg4b-ex26/out/sample_03.txt b/examples/testsets/apg4b-ex26/out/sample_03.txt deleted file mode 100644 index 7ed6ff8..0000000 --- a/examples/testsets/apg4b-ex26/out/sample_03.txt +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/examples/testsets/apg4b-ex26/out/sample_04.txt b/examples/testsets/apg4b-ex26/out/sample_04.txt deleted file mode 100644 index b4a1e66..0000000 --- a/examples/testsets/apg4b-ex26/out/sample_04.txt +++ /dev/null @@ -1 +0,0 @@ -[ 1 2 ] diff --git a/examples/testsets/apg4b-ex26/out/sample_05.txt b/examples/testsets/apg4b-ex26/out/sample_05.txt deleted file mode 100644 index d00491f..0000000 --- a/examples/testsets/apg4b-ex26/out/sample_05.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/examples/testsets/apg4b-ex26/out/sample_06.txt b/examples/testsets/apg4b-ex26/out/sample_06.txt deleted file mode 100644 index b6f6fec..0000000 --- a/examples/testsets/apg4b-ex26/out/sample_06.txt +++ /dev/null @@ -1 +0,0 @@ -[ 3 4 ] diff --git a/examples/testsets/apg4b-ex26/out/sample_07.txt b/examples/testsets/apg4b-ex26/out/sample_07.txt deleted file mode 100644 index 1e8b314..0000000 --- a/examples/testsets/apg4b-ex26/out/sample_07.txt +++ /dev/null @@ -1 +0,0 @@ -6 diff --git a/examples/testsets/apg4b-ex26/out/sample_08.txt b/examples/testsets/apg4b-ex26/out/sample_08.txt deleted file mode 100644 index b77f265..0000000 --- a/examples/testsets/apg4b-ex26/out/sample_08.txt +++ /dev/null @@ -1 +0,0 @@ -[ 12 15 18 ] diff --git a/examples/testsets/apg4b-ex26/out/sample_09.txt b/examples/testsets/apg4b-ex26/out/sample_09.txt deleted file mode 100644 index 20db499..0000000 --- a/examples/testsets/apg4b-ex26/out/sample_09.txt +++ /dev/null @@ -1,3 +0,0 @@ -[ 1 2 ] -[ 4 6 ] -[ -4 -4 ] diff --git a/examples/testsets/arc065-c/in/subtask0_0.txt b/examples/testsets/arc065-c/in/subtask0_0.txt deleted file mode 100644 index b2f36c5..0000000 --- a/examples/testsets/arc065-c/in/subtask0_0.txt +++ /dev/null @@ -1 +0,0 @@ -erasedream diff --git a/examples/testsets/arc065-c/in/subtask0_1.txt b/examples/testsets/arc065-c/in/subtask0_1.txt deleted file mode 100644 index afebb48..0000000 --- a/examples/testsets/arc065-c/in/subtask0_1.txt +++ /dev/null @@ -1 +0,0 @@ -dreameraser diff --git a/examples/testsets/arc065-c/in/subtask0_2.txt b/examples/testsets/arc065-c/in/subtask0_2.txt deleted file mode 100644 index 621f453..0000000 --- a/examples/testsets/arc065-c/in/subtask0_2.txt +++ /dev/null @@ -1 +0,0 @@ -dreamerer diff --git a/examples/testsets/arc065-c/out/subtask0_0.txt b/examples/testsets/arc065-c/out/subtask0_0.txt deleted file mode 100644 index f033a50..0000000 --- a/examples/testsets/arc065-c/out/subtask0_0.txt +++ /dev/null @@ -1 +0,0 @@ -YES diff --git a/examples/testsets/arc065-c/out/subtask0_1.txt b/examples/testsets/arc065-c/out/subtask0_1.txt deleted file mode 100644 index f033a50..0000000 --- a/examples/testsets/arc065-c/out/subtask0_1.txt +++ /dev/null @@ -1 +0,0 @@ -YES diff --git a/examples/testsets/arc065-c/out/subtask0_2.txt b/examples/testsets/arc065-c/out/subtask0_2.txt deleted file mode 100644 index 5e35d1b..0000000 --- a/examples/testsets/arc065-c/out/subtask0_2.txt +++ /dev/null @@ -1 +0,0 @@ -NO diff --git a/examples/testsets/arc084-c/in/s1.txt b/examples/testsets/arc084-c/in/s1.txt deleted file mode 100644 index 094d702..0000000 --- a/examples/testsets/arc084-c/in/s1.txt +++ /dev/null @@ -1,4 +0,0 @@ -2 -1 5 -2 4 -3 6 diff --git a/examples/testsets/arc084-c/in/s2.txt b/examples/testsets/arc084-c/in/s2.txt deleted file mode 100644 index a304b91..0000000 --- a/examples/testsets/arc084-c/in/s2.txt +++ /dev/null @@ -1,4 +0,0 @@ -3 -1 1 1 -2 2 2 -3 3 3 diff --git a/examples/testsets/arc084-c/in/s3.txt b/examples/testsets/arc084-c/in/s3.txt deleted file mode 100644 index ad6543d..0000000 --- a/examples/testsets/arc084-c/in/s3.txt +++ /dev/null @@ -1,4 +0,0 @@ -6 -3 14 159 2 6 53 -58 9 79 323 84 6 -2643 383 2 79 50 288 diff --git a/examples/testsets/arc084-c/out/s1.txt b/examples/testsets/arc084-c/out/s1.txt deleted file mode 100644 index 00750ed..0000000 --- a/examples/testsets/arc084-c/out/s1.txt +++ /dev/null @@ -1 +0,0 @@ -3 diff --git a/examples/testsets/arc084-c/out/s2.txt b/examples/testsets/arc084-c/out/s2.txt deleted file mode 100644 index f64f5d8..0000000 --- a/examples/testsets/arc084-c/out/s2.txt +++ /dev/null @@ -1 +0,0 @@ -27 diff --git a/examples/testsets/arc084-c/out/s3.txt b/examples/testsets/arc084-c/out/s3.txt deleted file mode 100644 index 84df352..0000000 --- a/examples/testsets/arc084-c/out/s3.txt +++ /dev/null @@ -1 +0,0 @@ -87 diff --git a/examples/testsets/atc001-b/in/00_sample_01.txt b/examples/testsets/atc001-b/in/00_sample_01.txt deleted file mode 100644 index 632a776..0000000 --- a/examples/testsets/atc001-b/in/00_sample_01.txt +++ /dev/null @@ -1,10 +0,0 @@ -8 9 -0 1 2 -0 3 2 -1 1 3 -1 1 4 -0 2 4 -1 4 1 -0 4 2 -0 0 0 -1 0 0 diff --git a/examples/testsets/atc001-b/out/00_sample_01.txt b/examples/testsets/atc001-b/out/00_sample_01.txt deleted file mode 100644 index df9be86..0000000 --- a/examples/testsets/atc001-b/out/00_sample_01.txt +++ /dev/null @@ -1,4 +0,0 @@ -Yes -No -Yes -Yes diff --git a/examples/testsets/atc002-b/in/sample_01.txt b/examples/testsets/atc002-b/in/sample_01.txt deleted file mode 100644 index 2065346..0000000 --- a/examples/testsets/atc002-b/in/sample_01.txt +++ /dev/null @@ -1 +0,0 @@ -12 15 7 diff --git a/examples/testsets/atc002-b/in/sample_02.txt b/examples/testsets/atc002-b/in/sample_02.txt deleted file mode 100644 index 0903e42..0000000 --- a/examples/testsets/atc002-b/in/sample_02.txt +++ /dev/null @@ -1 +0,0 @@ -123456789 234567894 6574837563712 diff --git a/examples/testsets/atc002-b/out/sample_01.txt b/examples/testsets/atc002-b/out/sample_01.txt deleted file mode 100644 index 00750ed..0000000 --- a/examples/testsets/atc002-b/out/sample_01.txt +++ /dev/null @@ -1 +0,0 @@ -3 diff --git a/examples/testsets/atc002-b/out/sample_02.txt b/examples/testsets/atc002-b/out/sample_02.txt deleted file mode 100644 index 7ecdf4c..0000000 --- a/examples/testsets/atc002-b/out/sample_02.txt +++ /dev/null @@ -1 +0,0 @@ -120678297 diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml index ce4670f..a0f2832 100644 --- a/test-with-generated-opts.toml +++ b/test-with-generated-opts.toml @@ -1,5 +1,7 @@ -# 手元でDropboxのテストケース(ある場合)で確認し、サンプルに含まれていないやつが大きいときはそれらをGitに入れない。 -# その場合CI上でもサンプルだけテストする。(Dropboxから引っ張るのも面倒だし何より誰のアカウントを使うかという問題がある) +# Dropboxからのダウンロードは行なわない。(面倒なのと誰のアカウントを使うかという問題がある) + +bin = "./target/test-with-generated-opts/bin/{}" +testcases = "./target/test-with-generated-opts/testcases/{}" [examples.abc054-c] name = "ABC054: C - One-stroke Path" @@ -50,6 +52,7 @@ matching = { FloatOr = { abs = 1e-6, rel = 1e-6 } } name = "APG4b: A - 1.00.はじめに" url = "https://atcoder.jp/contests/APG4b/tasks/APG4b_a" matching = "Exact" +alt_testcases = [{ in = "", out = "Hello, world!\n" }] [examples.apg4b-ex25] name = "APG4b: EX25 - 集合の操作 / 3.05" diff --git a/tools/test-with-generated-opts/Cargo.toml b/tools/test-with-generated-opts/Cargo.toml index 2f03bcf..3841904 100644 --- a/tools/test-with-generated-opts/Cargo.toml +++ b/tools/test-with-generated-opts/Cargo.toml @@ -12,10 +12,15 @@ env_logger = "0.7.1" indexmap = { version = "1.3.0", features = ["serde-1"] } itertools = "0.8.2" log = "0.4.8" +nom = "5.0.1" +once_cell = "1.2.0" +regex = "1.3.1" +scraper = "0.11.0" serde = { version = "1.0.104", features = ["derive"] } serde_json = "1.0.44" shell-escape = "0.1.4" structopt = "0.3.5" -tempdir = "0.3.7" toml = "0.5.5" +ureq = "0.11.2" +url = { version = "2.1.0", features = ["serde"] } which = { version = "3.1.0", default-features = false } diff --git a/tools/test-with-generated-opts/src/main.rs b/tools/test-with-generated-opts/src/main.rs index 0cae21a..493000f 100644 --- a/tools/test-with-generated-opts/src/main.rs +++ b/tools/test-with-generated-opts/src/main.rs @@ -1,18 +1,23 @@ -use anyhow::{anyhow, Context as _}; +use anyhow::{anyhow, ensure, Context as _}; use approx::{abs_diff_eq, relative_eq}; use env_logger::fmt::Color; use indexmap::IndexMap; use itertools::Itertools as _; use log::{info, Level, LevelFilter}; -use serde::Deserialize; +use once_cell::sync::Lazy; +use regex::Regex; +use scraper::{Html, Selector}; +use serde::de::DeserializeOwned; +use serde::{Deserialize, Deserializer}; use structopt::StructOpt; -use tempdir::TempDir; +use url::Url; -use std::collections::{BTreeMap, HashMap}; +use std::collections::BTreeMap; use std::ffi::{OsStr, OsString}; use std::io::{self, Read as _, Write as _}; use std::path::{Path, PathBuf}; use std::process::{Command, Output, Stdio}; +use std::str::FromStr; use std::time::Instant; use std::{env, f64, fs}; @@ -54,15 +59,13 @@ fn main() -> anyhow::Result<()> { .filter_module("test_with_generated_opts", LevelFilter::Info) .init(); - let Config { examples } = fs::read_to_string(&config) - .map_err(anyhow::Error::from) - .and_then(|s| toml::from_str(&s).map_err(Into::into)) - .with_context(|| format!("Failed to read {}", config.display()))?; + let config = read_toml::<_, Config>(config)?; - let tempdir = TempDir::new("atcoder-rust-base-test-with-generated-opts")?; + scrape_sample_cases(&config)?; - let tests = examples - .into_iter() + let tests = config + .examples + .iter() .map( |( slug, @@ -70,23 +73,301 @@ fn main() -> anyhow::Result<()> { name, url, matching, + alt_testcases, }, )| { - let src = Path::new("./examples").join(&slug).with_extension("rs"); - let testsets = Path::new("./examples/testsets").join(&slug); - let binary = compile(&src, tempdir.path(), &slug)?; - Ok((name, url, matching, testsets, binary)) + let testcases = if let Some(alt_testcases) = alt_testcases { + alt_testcases + .iter() + .enumerate() + .map(|(i, c)| ((i + 1).to_string().into(), (c.r#in.clone(), c.out.clone()))) + .collect() + } else { + load_testcases(&config.testcases.expand(slug))? + }; + let src = Path::new("./examples").join(slug).with_extension("rs"); + let bin = config.bin.expand(slug); + compile(&src, &bin)?; + Ok((name, url, *matching, testcases, bin)) }, ) .collect::>>()?; - for (name, url, matching, testsets, binary) in tests { - test(&name, &url, matching, &testsets, &binary)?; + for (name, url, matching, testcases, bin) in tests { + test(&name, &url, matching, &testcases, &bin)?; + } + Ok(()) +} + +fn scrape_sample_cases(config: &Config) -> anyhow::Result<()> { + for (slug, example) in &config.examples { + let dst_dir = config.testcases.expand(slug); + if !(dst_dir.exists() || example.alt_testcases.is_some()) { + let samples = get_html(&example.url)?.extract_samples()?; + save_testcases(&dst_dir, &samples)?; + } + } + Ok(()) +} + +fn get_html(url: &Url) -> anyhow::Result { + static USER_AGENT: &str = + "test-with-generated-opts "; + + info!("GET: {}", url); + + let res = ureq::get(url.as_ref()).set("User-Agent", USER_AGENT).call(); + + if let Some(err) = res.synthetic_error() { + let mut err = err as &dyn std::error::Error; + let mut displays = vec![err.to_string()]; + while let Some(source) = err.source() { + displays.push(source.to_string()); + err = source; + } + let mut displays = displays.into_iter().rev(); + let cause = anyhow!("{}", displays.next().unwrap()); + return Err(displays.fold(cause, |err, display| err.context(display))); + } + + info!("{} {}", res.status(), res.status_text()); + ensure!(res.status() == 200, "expected 200"); + let text = res.into_string()?; + Ok(Html::parse_document(&text)) +} + +trait HtmlExt { + fn extract_samples(&self) -> anyhow::Result>; +} + +impl HtmlExt for Html { + fn extract_samples(&self) -> anyhow::Result> { + fn extract_samples( + this: &Html, + selector_for_header: &'static Selector, + selector_for_content: &'static Selector, + re_input: &'static Regex, + re_output: &'static Regex, + ) -> Option> { + macro_rules! static_selector { + ($s:expr $(,)?) => {{ + static SELECTOR: Lazy = Lazy::new(|| Selector::parse($s).unwrap()); + &*SELECTOR + }}; + } + + macro_rules! guard { + ($p:expr $(,)?) => { + if !$p { + return None; + } + }; + } + + let task_statement = this + .select(static_selector!("#task-statement")) + .exactly_one() + .ok() + .or_else(|| { + this.select(static_selector!( + r#"div[id="task-statement"] > div[id="task-statement"]"#, + )) + .exactly_one() + .ok() + })?; + + let mut ins = BTreeMap::::new(); + let mut outs = BTreeMap::::new(); + let mut next = None; + let selector = selector_for_header.or(selector_for_content); + for elem_ref in task_statement.select(&selector) { + if elem_ref.value().name() == "h3" { + let text = elem_ref.text().join(""); + if let Some(caps) = re_input.captures(&text) { + next = Some((true, parse_possibly_zenkaku(&caps[1]).ok()?)); + } else if let Some(caps) = re_output.captures(&text) { + next = Some((false, parse_possibly_zenkaku(&caps[1]).ok()?)); + } + } else if ["pre", "section"].contains(&elem_ref.value().name()) { + if let Some((is_input, n)) = next { + let text = elem_ref.text().join(""); + if is_input { + ins.insert(n, text); + } else { + outs.insert(n, text); + } + } + next = None; + } + } + + let mut samples = ins + .into_iter() + .flat_map(|(idx, input)| outs.remove(&idx).map(|output| (input, output))) + .collect::>(); + + for (input, output) in &mut samples { + for s in &mut [input, output] { + if !(s.is_empty() || s.ends_with('\n')) { + s.push('\n'); + } + guard!(is_valid_text(s)); + } + } + + (!samples.is_empty()).then_(samples) + } + + fn parse_possibly_zenkaku(s: &str) -> Result { + s.parse().or_else(|err| { + if s.chars().all(|c| '0' <= c && c <= '9') { + s.chars() + .map(|c| { + char::from((u32::from(c) - u32::from('0') + u32::from('0')) as u8) + }) + .collect::() + .parse() + } else { + Err(err) + } + }) + } + + fn is_valid_text(s: &str) -> bool { + s == "\n" + || ![' ', '\n'].iter().any(|&c| s.starts_with(c)) + && s.chars().all(|c| { + c.is_ascii() && (c.is_ascii_whitespace() == [' ', '\n'].contains(&c)) + }) + } + + trait SelectorExt { + fn or(&self, other: &Self) -> Self; + } + + impl SelectorExt for Selector { + fn or(&self, other: &Self) -> Self { + let mut acc = self.clone(); + acc.selectors.extend(other.selectors.clone()); + acc + } + } + + macro_rules! lazy_regex { + ($s:expr $(,)?) => { + Lazy::new(|| Regex::new($s).unwrap()) + }; + } + + macro_rules! lazy_selector { + ($s:expr $(,)?) => { + Lazy::new(|| Selector::parse($s).unwrap()) + }; + } + + static IN_JA: Lazy = lazy_regex!(r"\A[\s\n]*入力例\s*(\d{1,2})[.\n]*\z"); + static OUT_JA: Lazy = lazy_regex!(r"\A[\s\n]*出力例\s*(\d{1,2})[.\n]*\z"); + static IN_EN: Lazy = lazy_regex!(r"\ASample Input\s?([0-9]{1,2}).*\z"); + static OUT_EN: Lazy = lazy_regex!(r"\ASample Output\s?([0-9]{1,2}).*\z"); + + // Current style (Japanese) + static P1_HEAD: Lazy = + lazy_selector!("span.lang > span.lang-ja > div.part > section > h3"); + static P1_CONTENT: Lazy = + lazy_selector!("span.lang > span.lang-ja > div.part > section > pre"); + // Current style (English) + static P2_HEAD: Lazy = + lazy_selector!("span.lang > span.lang-en > div.part > section > h3"); + static P2_CONTENT: Lazy = + lazy_selector!("span.lang>span.lang-en>div.part>section>pre"); + // ARC019..ARC057 \ {ARC019/C, ARC046/D, ARC050, ARC052/{A, C}, ARC053, ARC055}, + // ABC007..ABC040 \ {ABC036}, ATC001, ATC002 + static P3_HEAD: Lazy = lazy_selector!("div.part > section > h3"); + static P3_CONTENT: Lazy = lazy_selector!("div.part > section > pre"); + // ARC002..ARC018, ARC019/C, ABC001..ABC006 + static P4_HEAD: Lazy = lazy_selector!("div.part > h3,pre"); + static P4_CONTENT: Lazy = lazy_selector!("div.part > section > pre"); + // ARC001, dwacon2018-final/{A, B} + static P5_HEAD: Lazy = lazy_selector!("h3,pre"); + static P5_CONTENT: Lazy = lazy_selector!("section > pre"); + // ARC046/D, ARC050, ARC052/{A, C}, ARC053, ARC055, ABC036, ABC041 + static P6_HEAD: Lazy = lazy_selector!("section > h3"); + static P6_CONTENT: Lazy = lazy_selector!("section > pre"); + // ABC034 + static P7_HEAD: Lazy = lazy_selector!("span.lang > span.lang-ja > section > h3"); + static P7_CONTENT: Lazy = + lazy_selector!("span.lang > span.lang-ja > section > pre"); + // practice contest (Japanese) + static P8_HEAD: Lazy = lazy_selector!("span.lang > span.lang-ja > div.part > h3"); + static P8_CONTENT: Lazy = + lazy_selector!("span.lang > span.lang-ja > div.part > section > pre"); + + extract_samples(self, &P1_HEAD, &P1_CONTENT, &IN_JA, &OUT_JA) + .or_else(|| extract_samples(self, &P2_HEAD, &P2_CONTENT, &IN_EN, &OUT_EN)) + .or_else(|| extract_samples(self, &P3_HEAD, &P3_CONTENT, &IN_JA, &OUT_JA)) + .or_else(|| extract_samples(self, &P4_HEAD, &P4_CONTENT, &IN_JA, &OUT_JA)) + .or_else(|| extract_samples(self, &P5_HEAD, &P5_CONTENT, &IN_JA, &OUT_JA)) + .or_else(|| extract_samples(self, &P6_HEAD, &P6_CONTENT, &IN_JA, &OUT_JA)) + .or_else(|| extract_samples(self, &P7_HEAD, &P7_CONTENT, &IN_JA, &OUT_JA)) + .or_else(|| extract_samples(self, &P8_HEAD, &P8_CONTENT, &IN_JA, &OUT_JA)) + .ok_or_else(|| anyhow!("Failed to scrape")) + } +} + +fn save_testcases(dir: &Path, cases: &[(String, String)]) -> anyhow::Result<()> { + let contents = cases + .iter() + .enumerate() + .flat_map(|(idx, (input, output))| { + let file_name = format!("{}.txt", idx + 1); + let input = (dir.join("in").join(&file_name), input); + let output = (dir.join("out").join(file_name), output); + vec![input, output] + }) + .collect::>(); + + for (path, contents) in contents { + let parent = path.parent().expect("should not be root or empty"); + if !parent.exists() { + create_dir_all(parent)?; + } + write(&path, contents)?; + info!("Wrote {}", path.display()); } Ok(()) } -fn compile(src: &Path, tempdir: &Path, dir_name: &str) -> anyhow::Result { +fn load_testcases(dir: &Path) -> anyhow::Result> { + let find_files = |dir_file_name: &str| -> _ { + let dir = dir.join(dir_file_name); + (|| -> _ { + fs::read_dir(&dir)? + .flat_map(|entry| { + entry + .map(|entry| { + let path = entry.path(); + (path.extension() == Some("txt".as_ref())).then_with_(|| { + (path.file_stem().unwrap_or_default().to_owned(), path) + }) + }) + .transpose() + }) + .collect::>>() + })() + .with_context(|| format!("Failed to read {}", dir.display())) + }; + + let (ins, mut outs) = (find_files("in")?, find_files("out")?); + ins.into_iter() + .flat_map(|(stem, input)| outs.remove(&stem).map(|output| (stem, input, output))) + .map(|(stem, input, output)| { + let (input, output) = (read_to_string(input)?, read_to_string(output)?); + Ok((stem, (input, output))) + }) + .collect() +} + +fn compile(src: &Path, bin: &Path) -> anyhow::Result<()> { fn run_command, S2: AsRef, I: IntoIterator>( program: S1, args: I, @@ -116,6 +397,19 @@ fn compile(src: &Path, tempdir: &Path, dir_name: &str) -> anyhow::Result anyhow::Result anyhow::Result anyhow::Result, binary: &Path, ) -> anyhow::Result<()> { - let testsets = { - let find_files = |dir_file_name: &str| -> _ { - let dir = testsets.join(dir_file_name); - fs::read_dir(&dir) - .and_then(|read_dir| { - read_dir - .map(|entry| { - let path = entry?.path(); - let name = path - .file_stem() - .unwrap_or_default() - .to_string_lossy() - .into_owned(); - Ok((name, path)) - }) - .collect::>>() - }) - .with_context(|| format!("Failed to read {}", dir.display())) - }; - - let (ins, outs) = (find_files("in")?, find_files("out")?); - - ins.into_iter() - .flat_map(|(stem, path_in)| { - outs.get(&stem) - .map(|path_out| (stem, (path_in, path_out.clone()))) - }) - .collect::>() - }; - info!("Testing {}", binary.display()); info!(" Name: {:?}", task_name); info!(" URL: {}", url); - for (test_name, (path_in, path_out)) in testsets { - fn read_to_string(path: &Path) -> anyhow::Result { - fs::read_to_string(path).with_context(|| format!("Failed to read {}", path.display())) - } - - let input = read_to_string(&path_in)?; - let expected = read_to_string(&path_out)?; + for (case_name, (input, expected)) in testcases { let start = Instant::now(); let mut child = Command::new(binary) @@ -231,7 +483,7 @@ fn test( } else { "RE" }; - info!("{}: {} in {}ms", test_name, verdict, time); + info!("{:?}: {} in {}ms", case_name, verdict, time); if verdict != "AC" { return Err(anyhow!("Test failed")); } @@ -239,16 +491,133 @@ fn test( Ok(()) } +fn read_to_string(path: impl AsRef) -> anyhow::Result { + let path = path.as_ref(); + fs::read_to_string(path).with_context(|| format!("Failed to read {}", path.display())) +} + +fn read_toml, T: DeserializeOwned>(path: P) -> anyhow::Result { + let path = path.as_ref(); + fs::read_to_string(path) + .map_err(anyhow::Error::from) + .and_then(|s| toml::from_str(&s).map_err(Into::into)) + .with_context(|| format!("Failed to read {}", path.display())) +} + +fn write(path: impl AsRef, contents: impl AsRef) -> anyhow::Result<()> { + let (path, contents) = (path.as_ref(), contents.as_ref()); + fs::write(path, contents).with_context(|| format!("Failed to write {}", path.display())) +} + +fn create_dir_all(path: impl AsRef) -> anyhow::Result<()> { + let path = path.as_ref(); + fs::create_dir_all(path).with_context(|| format!("Failed to create {}", path.display())) +} + +trait BoolExt { + /// + fn then_(self, t: T) -> Option; + + /// + fn then_with_(self, f: F) -> Option + where + F: FnOnce() -> T; +} + +impl BoolExt for bool { + fn then_(self, t: T) -> Option { + if self { + Some(t) + } else { + None + } + } + + fn then_with_(self, f: F) -> Option + where + F: FnOnce() -> T, + { + if self { + Some(f()) + } else { + None + } + } +} + #[derive(Debug, Deserialize)] struct Config { + bin: PathTemplate, + testcases: PathTemplate, examples: IndexMap, } +#[derive(Debug)] +struct PathTemplate(Vec); + +impl PathTemplate { + fn expand(&self, slug: &str) -> PathBuf { + self.0 + .iter() + .map(|token| match token { + PathTemplateToken::Brace => slug, + PathTemplateToken::Plain(plain) => plain, + }) + .join("") + .into() + } +} + +impl<'de> Deserialize<'de> for PathTemplate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + use nom::branch::alt; + use nom::bytes::complete::take_while1; + use nom::character::complete::{char, space0}; + use nom::multi::many0; + use nom::IResult; + + fn tokens(input: &str) -> IResult<&str, Vec> { + many0(alt((brace, plain)))(input) + } + + fn brace(input: &str) -> IResult<&str, PathTemplateToken> { + let (input, _) = char('{')(input)?; + let (input, _) = space0(input)?; + let (input, _) = char('}')(input)?; + Ok((input, PathTemplateToken::Brace)) + } + + fn plain(input: &str) -> IResult<&str, PathTemplateToken> { + let (input, plain) = take_while1(|c| !['{', '}'].contains(&c))(input)?; + Ok((input, PathTemplateToken::Plain(plain.to_owned()))) + } + + let input = String::deserialize(deserializer)?; + let (_, tokens) = tokens(&input).map_err(|err| match err { + nom::Err::Incomplete(_) => unreachable!(), + nom::Err::Error((s, k)) | nom::Err::Failure((s, k)) => serde::de::Error::custom( + format!("{:?} at {}: {:?}", input, input.len() - s.len(), k), + ), + })?; + Ok(Self(tokens)) + } +} + +#[derive(Debug)] +enum PathTemplateToken { + Brace, + Plain(String), +} + #[derive(Debug, Deserialize)] struct Example { name: String, - url: String, + url: Url, matching: Matching, + alt_testcases: Option>, } #[derive(Debug, Clone, Copy, Deserialize)] @@ -292,3 +661,9 @@ impl Matching { } } } + +#[derive(Debug, Deserialize)] +struct AltTestCase { + r#in: String, + out: String, +} From ad381fde44837210659c8b686a80340e3e0284db Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Sun, 22 Dec 2019 13:07:28 +0900 Subject: [PATCH 12/39] Add an example for sumitrust2019-C --- examples/sumitrust2019-c.rs | 25 +++++++++++++++++++++++++ test-with-generated-opts.toml | 5 +++++ 2 files changed, 30 insertions(+) create mode 100644 examples/sumitrust2019-c.rs diff --git a/examples/sumitrust2019-c.rs b/examples/sumitrust2019-c.rs new file mode 100644 index 0000000..cd9d5fd --- /dev/null +++ b/examples/sumitrust2019-c.rs @@ -0,0 +1,25 @@ +// https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_c + +use defmac::defmac; +use fixedbitset::FixedBitSet; + +use std::io::{self, Read as _}; + +fn main() { + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + defmac!(read => input.next().unwrap().parse().unwrap()); + + let x: usize = read!(); + + let mut dp = FixedBitSet::with_capacity(x + 105); + dp.insert(0); + for i in 0..=x.saturating_sub(100) { + if dp[i] { + // `insert_range` does not accept `RangeInclusive`. + dp.insert_range(i + 100..i + 106); + } + } + println!("{}", u32::from(dp[x])); +} diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml index a0f2832..8c74bc2 100644 --- a/test-with-generated-opts.toml +++ b/test-with-generated-opts.toml @@ -83,3 +83,8 @@ matching = "Words" name = "ATC002: B - n^p mod m" url = "https://atcoder.jp/contests/atc002/tasks/atc002_b" matching = "Words" + +[examples.sumitrust2019-c] +name = "Sumitomo Mitsui Trust Bank Programming Contest 2019: C - 100 to 105" +url = "https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_c" +matching = "Words" From 80ac51cfe7a523e24aea648ef4985b514cc02e8a Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Fri, 10 Jan 2020 18:34:06 +0900 Subject: [PATCH 13/39] Modify an example --- examples/abc129-f.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/examples/abc129-f.rs b/examples/abc129-f.rs index 0fbd84c..ad0244f 100644 --- a/examples/abc129-f.rs +++ b/examples/abc129-f.rs @@ -22,7 +22,8 @@ fn main() { MOD.with(|cell| cell.set(m)); let count = |d| -> _ { - let count = |sup: u64| cmp::min(sup.saturating_sub(a + 1) / b + u64::from(b < sup), l); + let count = + |above: u64| cmp::min(above.saturating_sub(a + 1) / b + u64::from(b < above), l); count(10u64.pow(d)) - count(10u64.pow(d - 1)) }; @@ -65,12 +66,8 @@ thread_local! { struct Z(u64); impl Z { - fn checked(mut val: u64) -> Self { - let modulus = MOD.with(Cell::get); - if val >= modulus { - val %= modulus; - } - Self(val) + fn checked(val: u64) -> Self { + Self(val % MOD.with(Cell::get)) } } From 0ff2ac1dbec1b7fb572c8454d8ab5b8715115965 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Fri, 10 Jan 2020 20:08:06 +0900 Subject: [PATCH 14/39] Remove comments --- examples/abc084-d.rs | 2 -- examples/abc142-d.rs | 2 -- 2 files changed, 4 deletions(-) diff --git a/examples/abc084-d.rs b/examples/abc084-d.rs index 3747c2b..be215e6 100644 --- a/examples/abc084-d.rs +++ b/examples/abc084-d.rs @@ -40,8 +40,6 @@ fn main() { let q = read!(usize); let lrs = read!([(usize, usize); q]); - // サンプルケースでしか試してないので嘘かもしれない。 - let hi = lrs.iter().map(|&(_, r)| r).max().unwrap(); let sieve = Sieve::new(hi); let nums = (0..=hi) diff --git a/examples/abc142-d.rs b/examples/abc142-d.rs index fa4d093..feb0953 100644 --- a/examples/abc142-d.rs +++ b/examples/abc142-d.rs @@ -15,8 +15,6 @@ fn main() { let (a, b): (usize, usize) = (read!(), read!()); - // サンプルケースでしか試してないので嘘かもしれない。 - let sieve = Sieve::new(num_integer::sqrt(max(a, b))); let bases = |k| -> HashSet<_> { sieve From a823fa69acdd71a16a8874d8ad62494be7e1d782 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Sat, 11 Jan 2020 00:55:02 +0900 Subject: [PATCH 15/39] Add an example for ABC150-D --- examples/abc150-d.rs | 34 ++++++++++++++++++++++++++++++++++ test-with-generated-opts.toml | 5 +++++ 2 files changed, 39 insertions(+) create mode 100644 examples/abc150-d.rs diff --git a/examples/abc150-d.rs b/examples/abc150-d.rs new file mode 100644 index 0000000..bcc7f71 --- /dev/null +++ b/examples/abc150-d.rs @@ -0,0 +1,34 @@ +// https://atcoder.jp/contests/abc150/tasks/abc150_d + +use itertools::Itertools as _; + +use std::io::{self, Read as _}; + +fn main() { + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + macro_rules! read { + ([$tt:tt; $n:expr]) => { + (0..$n).map(|_| read!($tt)).collect::>() + }; + (($($tt:tt),+)) => { + ($(read!($tt)),*) + }; + ($ty:ty) => { + input.next().unwrap().parse::<$ty>().unwrap() + }; + } + + let (n, m) = read!((usize, usize)); + let a = read!([usize; n]); + + if !a.iter().copied().map(usize::trailing_zeros).all_equal() { + println!("0"); + return; + } + + let x0 = a.into_iter().fold(1, num::integer::lcm) / 2; + let ans = (m + x0) / (2 * x0); + println!("{}", ans); +} diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml index 8c74bc2..bb9ce14 100644 --- a/test-with-generated-opts.toml +++ b/test-with-generated-opts.toml @@ -48,6 +48,11 @@ name = "ABC144: D - Water Bottle" url = "https://atcoder.jp/contests/abc144/tasks/abc144_d" matching = { FloatOr = { abs = 1e-6, rel = 1e-6 } } +[examples.abc150-d] +name = "ABC150: D - Semi Common Multiple" +url = "https://atcoder.jp/contests/abc150/tasks/abc150_d" +matching = "Words" + [examples.apg4b-a] name = "APG4b: A - 1.00.はじめに" url = "https://atcoder.jp/contests/APG4b/tasks/APG4b_a" From 68c8e1115adf78b05e4cfdab70ab6b5bfba32a48 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Sat, 11 Jan 2020 23:04:33 +0900 Subject: [PATCH 16/39] Add an example for ABC141-C --- examples/abc141-c.rs | 22 ++++++++++++++++++++++ test-with-generated-opts.toml | 5 +++++ 2 files changed, 27 insertions(+) create mode 100644 examples/abc141-c.rs diff --git a/examples/abc141-c.rs b/examples/abc141-c.rs new file mode 100644 index 0000000..5cc7bc8 --- /dev/null +++ b/examples/abc141-c.rs @@ -0,0 +1,22 @@ +// https://atcoder.jp/contests/abc141/tasks/abc141_c + +use proconio::marker::Usize1; +use proconio::{fastout, input}; + +#[fastout] +fn main() { + input! { + n: usize, + k: usize, + q: usize, + a: [Usize1; q], + } + + let mut correct = vec![0; n]; + a.into_iter().for_each(|a| correct[a] += 1); + + for correct in correct { + let p = k + correct > q; + println!("{}", if p { "Yes" } else { "No" }); + } +} diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml index bb9ce14..576e024 100644 --- a/test-with-generated-opts.toml +++ b/test-with-generated-opts.toml @@ -38,6 +38,11 @@ name = "ABC129: F - Takahashi's Basics in Education and Learning" url = "https://atcoder.jp/contests/abc129/tasks/abc129_f" matching = "Words" +[examples.abc141-c] +name = "ABC141: C - Attack Survival" +url = "https://atcoder.jp/contests/abc141/tasks/abc141_c" +matching = "Words" + [examples.abc142-d] name = "ABC142: D - Disjoint Set of Common Divisors" url = "https://atcoder.jp/contests/abc142/tasks/abc142_d" From bd0b0db431f8787d106332cd032b64d91e70999a Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Sat, 11 Jan 2020 23:27:15 +0900 Subject: [PATCH 17/39] Note which example uses which crates --- test-with-generated-opts.toml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml index 576e024..71d63d8 100644 --- a/test-with-generated-opts.toml +++ b/test-with-generated-opts.toml @@ -7,94 +7,113 @@ testcases = "./target/test-with-generated-opts/testcases/{}" name = "ABC054: C - One-stroke Path" url = "https://atcoder.jp/contests/abc054/tasks/abc054_c" matching = "Words" +meta = { using = ["permutohedron", "petgraph"] } [examples.abc057-b] name = "ABC057: B - Checkpoints" url = "https://atcoder.jp/contests/abc057/tasks/abc057_b" matching = "Words" +meta = { using = ["text_io"] } [examples.abc084-d] name = "ABC084: D - 2017-like Number" url = "https://atcoder.jp/contests/abc084/tasks/abc084_d" matching = "Words" +meta = { using = ["itertools-num", "primal", "proconio"] } [examples.abc118-b] name = "ABC118: B - Foods Loved by Everyone" url = "https://atcoder.jp/contests/abc118/tasks/abc118_b" matching = "Words" +meta = { using = ["whiteread"] } [examples.abc120-d] name = "ABC120: D - Decayed Bridges" url = "https://atcoder.jp/contests/abc120/tasks/abc120_d" matching = "Words" +meta = { using = ["proconio", "union-find"] } [examples.abc121-b] name = "ABC121: B - Can you solve this?" url = "https://atcoder.jp/contests/abc121/tasks/abc121_b" matching = "Words" +meta = { using = ["proconio"] } [examples.abc129-f] name = "ABC129: F - Takahashi's Basics in Education and Learning" url = "https://atcoder.jp/contests/abc129/tasks/abc129_f" matching = "Words" +meta = { using = ["defmac", "derive_more", "ndarray", "num", "num-derive"] } [examples.abc141-c] name = "ABC141: C - Attack Survival" url = "https://atcoder.jp/contests/abc141/tasks/abc141_c" matching = "Words" +meta = { using = ["proconio"] } [examples.abc142-d] name = "ABC142: D - Disjoint Set of Common Divisors" url = "https://atcoder.jp/contests/abc142/tasks/abc142_d" matching = "Words" +meta = { using = ["defmac", "num-integer", "primal"] } [examples.abc144-d] name = "ABC144: D - Water Bottle" url = "https://atcoder.jp/contests/abc144/tasks/abc144_d" matching = { FloatOr = { abs = 1e-6, rel = 1e-6 } } +meta = { using = ["defmac", "libm"] } [examples.abc150-d] name = "ABC150: D - Semi Common Multiple" url = "https://atcoder.jp/contests/abc150/tasks/abc150_d" matching = "Words" +meta = { using = ["itertools", "num"] } [examples.apg4b-a] name = "APG4b: A - 1.00.はじめに" url = "https://atcoder.jp/contests/APG4b/tasks/APG4b_a" matching = "Exact" alt_testcases = [{ in = "", out = "Hello, world!\n" }] +meta = { using = ["aho-corasick", "alga", "approx", "ascii", "bitset-fixed", "defmac", "derive_more", "derive-new", "either", "euclid", "fixedbitset", "getrandom", "jemallocator", "jemalloc-ctl", "if_chain", "im-rc", "indexmap", "itertools", "itertools-num", "lazy_static", "libm", "maplit", "matches", "modtype", "nalgebra", "ndarray", "nom", "num", "num-bigint", "num-complex", "num-derive", "num-integer", "num-iter", "num-rational", "num-traits", "ordered-float", "permutohedron", "petgraph", "primal", "primal-check", "primal-estimate", "primal-sieve", "proconio", "rand", "rand_chacha", "rand_core", "rand_distr", "rand_hc", "rand_pcg", "regex", "rustc-hash", "smallvec", "strsim", "superslice", "take_mut", "text_io", "union-find", "whiteread"] } [examples.apg4b-ex25] name = "APG4b: EX25 - 集合の操作 / 3.05" url = "https://atcoder.jp/contests/APG4b/tasks/APG4b_bx" matching = "Words" +meta = { using = ["fixedbitset", "itertools"] } [examples.apg4b-ex26] name = "APG4b: EX26 - 電卓を作ろう3 / 3.06" url = "https://atcoder.jp/contests/APG4b/tasks/APG4b_bw" matching = "Exact" +meta = { using = ["itertools", "maplit", "matches", "nom"] } [examples.arc065-c] name = "ABC049 / ARC065: C - 白昼夢 / Daydream" url = "https://atcoder.jp/contests/arc065/tasks/arc065_a" matching = "Words" +meta = { using = ["lazy_static", "regex"] } [examples.arc084-c] name = "ABC077 / ARC084: C - Snuke Festival" url = "https://atcoder.jp/contests/arc084/tasks/arc084_a" matching = "Words" +meta = { using = ["superslice"] } [examples.atc001-b] name = "ATC001: B - Union Find" url = "https://atcoder.jp/contests/atc001/tasks/unionfind_a" matching = "Words" +meta = { using = ["petgraph", "proconio"] } [examples.atc002-b] name = "ATC002: B - n^p mod m" url = "https://atcoder.jp/contests/atc002/tasks/atc002_b" matching = "Words" +meta = { using = ["defmac", "num"] } [examples.sumitrust2019-c] name = "Sumitomo Mitsui Trust Bank Programming Contest 2019: C - 100 to 105" url = "https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_c" matching = "Words" +meta = { using = ["defmac", "fixedbitset"] } From 931fda820ca6549ba16eb3e25f9af253ae7ee75c Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Sat, 11 Jan 2020 23:50:05 +0900 Subject: [PATCH 18/39] Remove `fastout`s from some examples --- examples/abc084-d.rs | 46 +++++++++++++++------------------ examples/abc120-d.rs | 48 +++++++++++++++++------------------ examples/atc001-b.rs | 47 +++++++++++++++------------------- test-with-generated-opts.toml | 6 ++--- 4 files changed, 69 insertions(+), 78 deletions(-) diff --git a/examples/abc084-d.rs b/examples/abc084-d.rs index be215e6..9aa11b8 100644 --- a/examples/abc084-d.rs +++ b/examples/abc084-d.rs @@ -3,50 +3,46 @@ use itertools_num::ItertoolsNum as _; use primal::Sieve; -use std::io::{self, Read as _}; +use std::io::{self, BufWriter, Read as _, StdoutLock, Write as _}; -// `proconio::fastout` does not accept `macro_rules!` until Rust 1.40. -macro_rules! macro_rules_hack { - ($name:ident { $($tt:tt)* }) => { - macro_rules! $name { - $($tt)* - } - }; -} - -#[proconio::fastout] fn main() { let mut input = "".to_owned(); io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); - macro_rules_hack!(read { + macro_rules! read { ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; (($($tt:tt),+)) => { ($(read!($tt)),*) }; - (_1based) => { - read!(usize) - 1 - }; - (_bytes) => { - read!(String).into_bytes() - }; ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; - }); + } let q = read!(usize); let lrs = read!([(usize, usize); q]); - let hi = lrs.iter().map(|&(_, r)| r).max().unwrap(); - let sieve = Sieve::new(hi); - let nums = (0..=hi) + let max = lrs.iter().map(|&(_, r)| r).max().unwrap(); + let sieve = Sieve::new(max); + let nums = (0..=max) .map(|k| u32::from(sieve.is_prime(k) && sieve.is_prime((k + 1) / 2))) .cumsum() .collect::>(); - for (l, r) in lrs { - println!("{}", nums[r] - nums[l - 1]); - } + + buf_print(|stdout| { + macro_rules! println { ($($tt:tt)*) => { writeln!(stdout, $($tt)*).unwrap() }; } + + for (l, r) in lrs { + println!("{}", nums[r] - nums[l - 1]); + } + }); +} + +fn buf_print(f: impl FnOnce(&mut BufWriter)) { + let stdout = io::stdout(); + let mut stdout = BufWriter::new(stdout.lock()); + f(&mut stdout); + stdout.flush().unwrap(); } diff --git a/examples/abc120-d.rs b/examples/abc120-d.rs index f79079b..8425a07 100644 --- a/examples/abc120-d.rs +++ b/examples/abc120-d.rs @@ -2,23 +2,13 @@ use union_find::{QuickFindUf, UnionBySize, UnionFind as _}; -use std::io::{self, Read as _}; +use std::io::{self, BufWriter, Read as _, StdoutLock, Write as _}; -// `proconio::fastout` does not accept `macro_rules!` until Rust 1.40. -macro_rules! macro_rules_hack { - ($name:ident { $($tt:tt)* }) => { - macro_rules! $name { - $($tt)* - } - }; -} - -#[proconio::fastout] fn main() { let mut input = "".to_owned(); io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); - macro_rules_hack!(read { + macro_rules! read { ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; @@ -28,29 +18,39 @@ fn main() { (_1based) => { read!(usize) - 1 }; - (_bytes) => { - read!(String).into_bytes() - }; ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; - }); + } let (n, m) = read!((usize, usize)); let abs = read!([(_1based, _1based); m]); + let max = n * (n - 1) / 2; let mut uf = QuickFindUf::::new(n); - let mut k = n * (n - 1) / 2; - let mut ans_rev = vec![k]; - ans_rev.extend(abs.into_iter().rev().map(|(a, b)| { + let mut ans_rev = vec![max]; + + ans_rev.extend(abs.into_iter().rev().scan(max, |cur, (a, b)| { let p = uf.get(a).size() * uf.get(b).size(); if uf.union(a, b) { - k -= p; + *cur -= p; } - k + Some(*cur) })); assert_eq!(ans_rev.pop(), Some(0)); - for x in ans_rev.into_iter().rev() { - println!("{}", x); - } + + buf_print(|stdout| { + macro_rules! println { ($($tt:tt)*) => { writeln!(stdout, $($tt)*).unwrap() }; } + + for x in ans_rev.into_iter().rev() { + println!("{}", x); + } + }); +} + +fn buf_print(f: impl FnOnce(&mut BufWriter)) { + let stdout = io::stdout(); + let mut stdout = BufWriter::new(stdout.lock()); + f(&mut stdout); + stdout.flush().unwrap(); } diff --git a/examples/atc001-b.rs b/examples/atc001-b.rs index 9d16d6a..ff4ccf2 100644 --- a/examples/atc001-b.rs +++ b/examples/atc001-b.rs @@ -2,50 +2,45 @@ use petgraph::unionfind::UnionFind; -use std::io::{self, Read as _}; +use std::io::{self, BufWriter, Read as _, StdoutLock, Write as _}; -// `proconio::fastout` does not accept `macro_rules!` until Rust 1.40. -macro_rules! macro_rules_hack { - ($name:ident { $($tt:tt)* }) => { - macro_rules! $name { - $($tt)* - } - }; -} - -#[proconio::fastout] fn main() { let mut input = "".to_owned(); io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); - macro_rules_hack!(read { + macro_rules! read { ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; (($($tt:tt),+)) => { ($(read!($tt)),*) }; - (_1based) => { - read!(usize) - 1 - }; - (_bytes) => { - read!(String).into_bytes() - }; ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; - }); + } let (n, q) = read!((usize, usize)); let pabs = read!([(u8, usize, usize); q]); let mut uf = UnionFind::new(n); - for (p, a, b) in pabs { - if p == 1 { - let same = uf.find(a) == uf.find(b); - println!("{}", if same { "Yes" } else { "No" }); - } else { - uf.union(a, b); + buf_print(|stdout| { + macro_rules! println { ($($tt:tt)*) => { writeln!(stdout, $($tt)*).unwrap() }; } + + for (p, a, b) in pabs { + if p == 1 { + let same = uf.find(a) == uf.find(b); + println!("{}", if same { "Yes" } else { "No" }); + } else { + uf.union(a, b); + } } - } + }); +} + +fn buf_print(f: impl FnOnce(&mut BufWriter)) { + let stdout = io::stdout(); + let mut stdout = BufWriter::new(stdout.lock()); + f(&mut stdout); + stdout.flush().unwrap(); } diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml index 71d63d8..34ea2f3 100644 --- a/test-with-generated-opts.toml +++ b/test-with-generated-opts.toml @@ -19,7 +19,7 @@ meta = { using = ["text_io"] } name = "ABC084: D - 2017-like Number" url = "https://atcoder.jp/contests/abc084/tasks/abc084_d" matching = "Words" -meta = { using = ["itertools-num", "primal", "proconio"] } +meta = { using = ["itertools-num", "primal"] } [examples.abc118-b] name = "ABC118: B - Foods Loved by Everyone" @@ -31,7 +31,7 @@ meta = { using = ["whiteread"] } name = "ABC120: D - Decayed Bridges" url = "https://atcoder.jp/contests/abc120/tasks/abc120_d" matching = "Words" -meta = { using = ["proconio", "union-find"] } +meta = { using = ["union-find"] } [examples.abc121-b] name = "ABC121: B - Can you solve this?" @@ -104,7 +104,7 @@ meta = { using = ["superslice"] } name = "ATC001: B - Union Find" url = "https://atcoder.jp/contests/atc001/tasks/unionfind_a" matching = "Words" -meta = { using = ["petgraph", "proconio"] } +meta = { using = ["petgraph"] } [examples.atc002-b] name = "ATC002: B - n^p mod m" From 3d74af8ad5e78d6daafcf8d64f11407f276cf0fe Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Sun, 12 Jan 2020 03:48:09 +0900 Subject: [PATCH 19/39] More input examples --- examples/abc057-b-naive.rs | 33 ++++++++++ examples/abc057-b-proconio.rs | 22 +++++++ examples/{abc057-b.rs => abc057-b-text-io.rs} | 0 examples/abc057-b-whiteread.rs | 21 +++++++ examples/abc118-b-naive.rs | 36 +++++++++++ examples/abc118-b-proconio.rs | 21 +++++++ examples/abc118-b-text-io.rs | 27 +++++++++ .../{abc118-b.rs => abc118-b-whiteread.rs} | 0 examples/abc121-b-naive.rs | 30 ++++++++++ .../{abc121-b.rs => abc121-b-proconio.rs} | 0 examples/abc121-b-text-io.rs | 18 ++++++ examples/abc121-b-whiteread.rs | 19 ++++++ test-with-generated-opts.toml | 60 ++++++++++++++++++- 13 files changed, 284 insertions(+), 3 deletions(-) create mode 100644 examples/abc057-b-naive.rs create mode 100644 examples/abc057-b-proconio.rs rename examples/{abc057-b.rs => abc057-b-text-io.rs} (100%) create mode 100644 examples/abc057-b-whiteread.rs create mode 100644 examples/abc118-b-naive.rs create mode 100644 examples/abc118-b-proconio.rs create mode 100644 examples/abc118-b-text-io.rs rename examples/{abc118-b.rs => abc118-b-whiteread.rs} (100%) create mode 100644 examples/abc121-b-naive.rs rename examples/{abc121-b.rs => abc121-b-proconio.rs} (100%) create mode 100644 examples/abc121-b-text-io.rs create mode 100644 examples/abc121-b-whiteread.rs diff --git a/examples/abc057-b-naive.rs b/examples/abc057-b-naive.rs new file mode 100644 index 0000000..6ff92c8 --- /dev/null +++ b/examples/abc057-b-naive.rs @@ -0,0 +1,33 @@ +// https://atcoder.jp/contests/abc057/tasks/abc057_b + +use std::io::{self, Read as _}; + +fn main() { + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + macro_rules! read { + ([$tt:tt; $n:expr]) => { + (0..$n).map(|_| read!($tt)).collect::>() + }; + (($($tt:tt),+)) => { + ($(read!($tt)),*) + }; + ($ty:ty) => { + input.next().unwrap().parse::<$ty>().unwrap() + }; + } + + let (n, m) = read!((usize, usize)); + let (abs, cds) = read!(([(i64, i64); n], [(i64, i64); m])); + + for (a, b) in abs { + let j = (0..m) + .min_by_key(|&j| { + let (c, d) = cds[j]; + (a - c).abs() + (b - d).abs() + }) + .unwrap(); + println!("{}", j + 1); + } +} diff --git a/examples/abc057-b-proconio.rs b/examples/abc057-b-proconio.rs new file mode 100644 index 0000000..7f652e8 --- /dev/null +++ b/examples/abc057-b-proconio.rs @@ -0,0 +1,22 @@ +// https://atcoder.jp/contests/abc057/tasks/abc057_b + +use proconio::input; + +fn main() { + input! { + n: usize, + m: usize, + abs: [(i64, i64); n], + cds: [(i64, i64); m], + } + + for (a, b) in abs { + let j = (0..m) + .min_by_key(|&j| { + let (c, d) = cds[j]; + (a - c).abs() + (b - d).abs() + }) + .unwrap(); + println!("{}", j + 1); + } +} diff --git a/examples/abc057-b.rs b/examples/abc057-b-text-io.rs similarity index 100% rename from examples/abc057-b.rs rename to examples/abc057-b-text-io.rs diff --git a/examples/abc057-b-whiteread.rs b/examples/abc057-b-whiteread.rs new file mode 100644 index 0000000..4f7b8c8 --- /dev/null +++ b/examples/abc057-b-whiteread.rs @@ -0,0 +1,21 @@ +// https://atcoder.jp/contests/abc057/tasks/abc057_b + +use whiteread::Reader; + +fn main() { + let mut rdr = Reader::from_stdin_naive(); + + let (n, m) = rdr.p::<(usize, usize)>(); + let abs = (0..n).map(|_| rdr.p()).collect::>(); + let cds = (0..m).map(|_| rdr.p()).collect::>(); + + for (a, b) in abs { + let j = (0..m) + .min_by_key(|&j| { + let (c, d) = cds[j]; + (a - c).abs() + (b - d).abs() + }) + .unwrap(); + println!("{}", j + 1); + } +} diff --git a/examples/abc118-b-naive.rs b/examples/abc118-b-naive.rs new file mode 100644 index 0000000..1cd1e39 --- /dev/null +++ b/examples/abc118-b-naive.rs @@ -0,0 +1,36 @@ +// https://atcoder.jp/contests/abc118/tasks/abc118_b + +use std::io::{self, Read as _}; +use std::ops::{BitAnd, BitOr}; + +fn main() { + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + macro_rules! read { + ([$tt:tt; $n:expr]) => { + (0..$n).map(|_| read!($tt)).collect::>() + }; + (($($tt:tt),+)) => { + ($(read!($tt)),*) + }; + (_1based) => { + read!(usize) - 1 + }; + ($ty:ty) => { + input.next().unwrap().parse::<$ty>().unwrap() + }; + } + + let (n, _) = read!((usize, usize)); + let a = (0..n) + .map(|_| read!([_1based; read!(usize)])) + .collect::>(); + + let ans = a + .into_iter() + .map(|row| row.into_iter().map(|k| 1 << k).fold(0, BitOr::bitor)) + .fold(usize::max_value(), BitAnd::bitand) + .count_ones(); + println!("{}", ans); +} diff --git a/examples/abc118-b-proconio.rs b/examples/abc118-b-proconio.rs new file mode 100644 index 0000000..722a1e4 --- /dev/null +++ b/examples/abc118-b-proconio.rs @@ -0,0 +1,21 @@ +// https://atcoder.jp/contests/abc118/tasks/abc118_b + +use proconio::input; +use proconio::marker::Usize1; + +use std::ops::{BitAnd, BitOr}; + +fn main() { + input! { + n: usize, + _m: usize, + a: [[Usize1]; n], + } + + let ans = a + .into_iter() + .map(|row| row.into_iter().map(|k| 1 << k).fold(0, BitOr::bitor)) + .fold(usize::max_value(), BitAnd::bitand) + .count_ones(); + println!("{}", ans); +} diff --git a/examples/abc118-b-text-io.rs b/examples/abc118-b-text-io.rs new file mode 100644 index 0000000..2cef31d --- /dev/null +++ b/examples/abc118-b-text-io.rs @@ -0,0 +1,27 @@ +// https://atcoder.jp/contests/abc118/tasks/abc118_b + +use text_io::{read, try_read, try_scan}; + +use std::ops::{BitAnd, BitOr}; + +#[allow(clippy::try_err)] +fn main() { + let (n, _): (usize, usize) = (read!(), read!()); + let a = (0..n) + .map(|_| { + (0..read!()) + .map(|_| { + let a: usize = read!(); + a - 1 + }) + .collect() + }) + .collect::>>(); + + let ans = a + .into_iter() + .map(|row| row.into_iter().map(|k| 1 << k).fold(0, BitOr::bitor)) + .fold(usize::max_value(), BitAnd::bitand) + .count_ones(); + println!("{}", ans); +} diff --git a/examples/abc118-b.rs b/examples/abc118-b-whiteread.rs similarity index 100% rename from examples/abc118-b.rs rename to examples/abc118-b-whiteread.rs diff --git a/examples/abc121-b-naive.rs b/examples/abc121-b-naive.rs new file mode 100644 index 0000000..951e19d --- /dev/null +++ b/examples/abc121-b-naive.rs @@ -0,0 +1,30 @@ +// https://atcoder.jp/contests/abc121/tasks/abc121_b + +use std::io::{self, Read as _}; + +#[allow(clippy::many_single_char_names)] +fn main() { + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + macro_rules! read { + ([$tt:tt; $n:expr]) => { + (0..$n).map(|_| read!($tt)).collect::>() + }; + (($($tt:tt),+)) => { + ($(read!($tt)),*) + }; + ($ty:ty) => { + input.next().unwrap().parse::<$ty>().unwrap() + }; + } + + let (n, m, c) = read!((usize, usize, i32)); + let (b, a) = read!(([i32; m], [[i32; m]; n])); + + let ans = a + .into_iter() + .filter(|a| a.iter().zip(&b).map(|(a, b)| a * b).sum::() + c > 0) + .count(); + println!("{}", ans); +} diff --git a/examples/abc121-b.rs b/examples/abc121-b-proconio.rs similarity index 100% rename from examples/abc121-b.rs rename to examples/abc121-b-proconio.rs diff --git a/examples/abc121-b-text-io.rs b/examples/abc121-b-text-io.rs new file mode 100644 index 0000000..3c7ab2d --- /dev/null +++ b/examples/abc121-b-text-io.rs @@ -0,0 +1,18 @@ +// https://atcoder.jp/contests/abc121/tasks/abc121_b + +use text_io::{read, try_read, try_scan}; + +#[allow(clippy::many_single_char_names, clippy::try_err)] +fn main() { + let (n, m, c): (usize, usize, i32) = (read!(), read!(), read!()); + let b = (0..m).map(|_| read!()).collect::>(); + let a = (0..n) + .map(|_| (0..m).map(|_| read!()).collect()) + .collect::>>(); + + let ans = a + .into_iter() + .filter(|a| a.iter().zip(&b).map(|(a, b)| a * b).sum::() + c > 0) + .count(); + println!("{}", ans); +} diff --git a/examples/abc121-b-whiteread.rs b/examples/abc121-b-whiteread.rs new file mode 100644 index 0000000..7648be9 --- /dev/null +++ b/examples/abc121-b-whiteread.rs @@ -0,0 +1,19 @@ +// https://atcoder.jp/contests/abc121/tasks/abc121_b + +use whiteread::Reader; + +fn main() { + let mut rdr = Reader::from_stdin_naive(); + + let (n, _, c) = rdr.p::<(usize, usize, i32)>(); + let b = rdr.line::>().unwrap(); + let a = (0..n) + .map(|_| rdr.line().unwrap()) + .collect::>>(); + + let ans = a + .into_iter() + .filter(|a| a.iter().zip(&b).map(|(a, b)| a * b).sum::() + c > 0) + .count(); + println!("{}", ans); +} diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml index 34ea2f3..5a96e8b 100644 --- a/test-with-generated-opts.toml +++ b/test-with-generated-opts.toml @@ -9,19 +9,55 @@ url = "https://atcoder.jp/contests/abc054/tasks/abc054_c" matching = "Words" meta = { using = ["permutohedron", "petgraph"] } -[examples.abc057-b] +[examples.abc057-b-naive] +name = "ABC057: B - Checkpoints" +url = "https://atcoder.jp/contests/abc057/tasks/abc057_b" +matching = "Words" +meta = { using = [] } # 下3つと比較するため + +[examples.abc057-b-proconio] +name = "ABC057: B - Checkpoints" +url = "https://atcoder.jp/contests/abc057/tasks/abc057_b" +matching = "Words" +meta = { using = ["proconio"] } + +[examples.abc057-b-text-io] name = "ABC057: B - Checkpoints" url = "https://atcoder.jp/contests/abc057/tasks/abc057_b" matching = "Words" meta = { using = ["text_io"] } +[examples.abc057-b-whiteread] +name = "ABC057: B - Checkpoints" +url = "https://atcoder.jp/contests/abc057/tasks/abc057_b" +matching = "Words" +meta = { using = ["whiteread"] } + [examples.abc084-d] name = "ABC084: D - 2017-like Number" url = "https://atcoder.jp/contests/abc084/tasks/abc084_d" matching = "Words" meta = { using = ["itertools-num", "primal"] } -[examples.abc118-b] +[examples.abc118-b-naive] +name = "ABC118: B - Foods Loved by Everyone" +url = "https://atcoder.jp/contests/abc118/tasks/abc118_b" +matching = "Words" +meta = { using = [] } # 下3つと比較するため + +[examples.abc118-b-proconio] +name = "ABC118: B - Foods Loved by Everyone" +url = "https://atcoder.jp/contests/abc118/tasks/abc118_b" +matching = "Words" +meta = { using = ["proconio"] } + +[examples.abc118-b-text-io] +name = "ABC118: B - Foods Loved by Everyone" +url = "https://atcoder.jp/contests/abc118/tasks/abc118_b" +matching = "Words" +meta = { using = ["text-io"] } + +[examples.abc118-b-whiteread] name = "ABC118: B - Foods Loved by Everyone" url = "https://atcoder.jp/contests/abc118/tasks/abc118_b" matching = "Words" @@ -33,12 +69,30 @@ url = "https://atcoder.jp/contests/abc120/tasks/abc120_d" matching = "Words" meta = { using = ["union-find"] } -[examples.abc121-b] +[examples.abc121-b-naive] +name = "ABC121: B - Can you solve this?" +url = "https://atcoder.jp/contests/abc121/tasks/abc121_b" +matching = "Words" +meta = { using = [] } # 下3つと比較するため + +[examples.abc121-b-proconio] name = "ABC121: B - Can you solve this?" url = "https://atcoder.jp/contests/abc121/tasks/abc121_b" matching = "Words" meta = { using = ["proconio"] } +[examples.abc121-b-text-io] +name = "ABC121: B - Can you solve this?" +url = "https://atcoder.jp/contests/abc121/tasks/abc121_b" +matching = "Words" +meta = { using = ["text_io"] } + +[examples.abc121-b-whiteread] +name = "ABC121: B - Can you solve this?" +url = "https://atcoder.jp/contests/abc121/tasks/abc121_b" +matching = "Words" +meta = { using = ["whiteread"] } + [examples.abc129-f] name = "ABC129: F - Takahashi's Basics in Education and Learning" url = "https://atcoder.jp/contests/abc129/tasks/abc129_f" From 21b945c89228b8fe622d5296e2df29c7f6a63fe1 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Sun, 12 Jan 2020 04:04:49 +0900 Subject: [PATCH 20/39] Remove dead arms --- examples/abc054-c.rs | 3 --- examples/apg4b-ex25.rs | 9 --------- examples/arc084-c.rs | 6 ------ 3 files changed, 18 deletions(-) diff --git a/examples/abc054-c.rs b/examples/abc054-c.rs index a1cde35..4f19669 100644 --- a/examples/abc054-c.rs +++ b/examples/abc054-c.rs @@ -19,9 +19,6 @@ fn main() { (_1based) => { read!(usize) - 1 }; - (_bytes) => { - read!(String).into_bytes() - }; ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; diff --git a/examples/apg4b-ex25.rs b/examples/apg4b-ex25.rs index 81e2cd1..369d5f4 100644 --- a/examples/apg4b-ex25.rs +++ b/examples/apg4b-ex25.rs @@ -15,15 +15,6 @@ fn main() { ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; - (($($tt:tt),+)) => { - ($(read!($tt)),*) - }; - (_1based) => { - read!(usize) - 1 - }; - (_bytes) => { - read!(String).into_bytes() - }; ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; diff --git a/examples/arc084-c.rs b/examples/arc084-c.rs index 558fd6e..0936d67 100644 --- a/examples/arc084-c.rs +++ b/examples/arc084-c.rs @@ -15,12 +15,6 @@ fn main() { (($($tt:tt),+)) => { ($(read!($tt)),*) }; - (_1based) => { - read!(usize) - 1 - }; - (_bytes) => { - read!(String).into_bytes() - }; ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; From 012a8b73e647a586c014d86b8e2c4a13dba28125 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Sun, 12 Jan 2020 17:41:39 +0900 Subject: [PATCH 21/39] Modify some examples --- examples/abc054-c.rs | 12 ++++-------- examples/abc129-f.rs | 14 +++++++------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/examples/abc054-c.rs b/examples/abc054-c.rs index 4f19669..3629ddf 100644 --- a/examples/abc054-c.rs +++ b/examples/abc054-c.rs @@ -1,7 +1,6 @@ // https://atcoder.jp/contests/abc054/tasks/abc054_c -use petgraph::csr::Csr; -use petgraph::Undirected; +use petgraph::matrix_graph::UnMatrix; use std::io::{self, Read as _}; @@ -27,14 +26,11 @@ fn main() { let (n, m) = read!((usize, usize)); let abs = read!([(_1based, _1based); m]); - let mut graph = Csr::<(), (), Undirected, usize>::with_nodes(n); - for (a, b) in abs { - graph.add_edge(a, b, ()); - } + let graph = UnMatrix::<(), (), Option<()>, usize>::from_edges(abs); let mut ans = 0; - let mut nodes = (0..n).collect::>(); + let mut nodes = (0..n).map(Into::into).collect::>(); permutohedron::heap_recursive(&mut nodes, |nodes| { - if nodes[0] == 0 && nodes.windows(2).all(|w| graph.contains_edge(w[0], w[1])) { + if nodes[0] == 0.into() && nodes.windows(2).all(|w| graph.has_edge(w[0], w[1])) { ans += 1; } }); diff --git a/examples/abc129-f.rs b/examples/abc129-f.rs index ad0244f..6f5b9eb 100644 --- a/examples/abc129-f.rs +++ b/examples/abc129-f.rs @@ -27,12 +27,12 @@ fn main() { count(10u64.pow(d)) - count(10u64.pow(d - 1)) }; - let ans = (1..=18).fold(array![[Z(0), Z::checked(a), Z(1)]], |acc, d| { + let ans = (1..=18).fold(array![[Z::new(0), Z::new(a), Z::new(1)]], |acc, d| { acc.dot( &array![ - [Z::checked(10u64.pow(d)), Z(0), Z(0)], - [Z(1), Z(1), Z(0)], - [Z(0), Z::checked(b), Z(1)], + [Z::new(10u64.pow(d)), Z::new(0), Z::new(0)], + [Z::new(1), Z::new(1), Z::new(0)], + [Z::new(0), Z::new(b), Z::new(1)], ] .matrix_power(count(d)), ) @@ -66,7 +66,7 @@ thread_local! { struct Z(u64); impl Z { - fn checked(val: u64) -> Self { + fn new(val: u64) -> Self { Self(val % MOD.with(Cell::get)) } } @@ -75,7 +75,7 @@ impl Add for Z { type Output = Self; fn add(self, rhs: Self) -> Self { - Self::checked(self.0 + rhs.0) + Self::new(self.0 + rhs.0) } } @@ -91,7 +91,7 @@ impl Mul for Z { type Output = Self; fn mul(self, rhs: Self) -> Self { - Self::checked(self.0 * rhs.0) + Self::new(self.0 * rhs.0) } } From 03a8d149448d4f5e73894a18f321f218294f9ebb Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Mon, 13 Jan 2020 08:07:15 +0900 Subject: [PATCH 22/39] Add an example for ABC151-D --- examples/abc151-d.rs | 76 +++++++++++++++++++++++++++++++++++ test-with-generated-opts.toml | 6 +++ 2 files changed, 82 insertions(+) create mode 100644 examples/abc151-d.rs diff --git a/examples/abc151-d.rs b/examples/abc151-d.rs new file mode 100644 index 0000000..c4eb931 --- /dev/null +++ b/examples/abc151-d.rs @@ -0,0 +1,76 @@ +// https://atcoder.jp/contests/abc151/tasks/abc151_d + +use ndarray::Array; +use smallvec::{smallvec, SmallVec}; + +use std::collections::VecDeque; +use std::io::{self, Read as _}; +use std::iter; + +fn main() { + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + macro_rules! read { + (($($tt:tt),+)) => { + ($(read!($tt)),*) + }; + (_maze<$c:literal, ($h:expr, $w:expr)>) => { + Array::from_shape_vec( + ($h, $w), + (0..$h) + .fold(vec![], |mut acc, _| { + acc.extend(input.next().unwrap().bytes().map(|c| c == $c)); + acc + }), + ) + .unwrap() + }; + ($ty:ty) => { + input.next().unwrap().parse::<$ty>().unwrap() + }; + } + + let (h, w) = read!((usize, usize)); + let maze = read!(_maze); + + let neighbors = Array::from_shape_fn((h, w), |(i, j)| -> SmallVec<[_; 4]> { + let mut neighbors = smallvec![]; + macro_rules! push { + (if $cond:expr => $pos:expr) => { + if $cond && maze[$pos] { + neighbors.push($pos); + } + }; + } + push!(if 0 < i => (i - 1, j)); + push!(if i < h - 1 => (i + 1, j)); + push!(if 0 < j => (i, j - 1)); + push!(if j < w - 1 => (i, j + 1)); + neighbors + }); + + let ans = (0..h) + .flat_map(|i| (0..w).map(move |j| (i, j))) + .filter(|&p| maze[p]) + .map(|start| { + let mut longest = 0; + let mut queue = iter::once((start, 0)).collect::>(); + let mut unvisited = maze.clone(); + unvisited[start] = false; + + while let Some((pos, dist)) = queue.pop_front() { + for &neighbor in &neighbors[pos] { + if unvisited[neighbor] { + unvisited[neighbor] = false; + longest = dist + 1; + queue.push_back((neighbor, longest)); + } + } + } + longest + }) + .max() + .unwrap(); + println!("{}", ans); +} diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml index 5a96e8b..f8c7a4d 100644 --- a/test-with-generated-opts.toml +++ b/test-with-generated-opts.toml @@ -123,6 +123,12 @@ url = "https://atcoder.jp/contests/abc150/tasks/abc150_d" matching = "Words" meta = { using = ["itertools", "num"] } +[examples.abc151-d] +name = "ABC151: D - Maze Master" +url = "https://atcoder.jp/contests/abc151/tasks/abc151_d" +matching = "Words" +meta = { using = ["ndarray", "smallvec"] } + [examples.apg4b-a] name = "APG4b: A - 1.00.はじめに" url = "https://atcoder.jp/contests/APG4b/tasks/APG4b_a" From 2df3e1e18ba6a19d1bd3bcc904cda060c0d05c2c Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Tue, 14 Jan 2020 19:56:17 +0900 Subject: [PATCH 23/39] Collapse `read!`s --- examples/abc054-c.rs | 21 +++++++-------------- examples/abc057-b-naive.rs | 12 +++--------- examples/abc084-d.rs | 16 +++++----------- examples/abc118-b-naive.rs | 21 ++++++--------------- examples/abc120-d.rs | 25 +++++++++---------------- examples/abc121-b-naive.rs | 12 +++--------- examples/abc150-d.rs | 12 +++--------- examples/apg4b-ex25.rs | 19 +++++++------------ examples/arc065-c.rs | 8 +++++++- examples/arc084-c.rs | 12 +++--------- examples/atc001-b.rs | 17 ++++++----------- 11 files changed, 59 insertions(+), 116 deletions(-) diff --git a/examples/abc054-c.rs b/examples/abc054-c.rs index 3629ddf..6f7a15e 100644 --- a/examples/abc054-c.rs +++ b/examples/abc054-c.rs @@ -9,22 +9,15 @@ fn main() { io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); macro_rules! read { - ([$tt:tt; $n:expr]) => { - (0..$n).map(|_| read!($tt)).collect::>() - }; - (($($tt:tt),+)) => { - ($(read!($tt)),*) - }; - (_1based) => { - read!(usize) - 1 - }; - ($ty:ty) => { - input.next().unwrap().parse::<$ty>().unwrap() - }; + ([$tt:tt]) => { read!([$tt; read!(usize)]) }; + ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; + (($($tt:tt),+)) => { ($(read!($tt)),*) }; + (_1based) => { read!(usize) - 1 }; + ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; } - let (n, m) = read!((usize, usize)); - let abs = read!([(_1based, _1based); m]); + let n = read!(usize); + let abs = read!([(_1based, _1based)]); let graph = UnMatrix::<(), (), Option<()>, usize>::from_edges(abs); let mut ans = 0; diff --git a/examples/abc057-b-naive.rs b/examples/abc057-b-naive.rs index 6ff92c8..3e96f69 100644 --- a/examples/abc057-b-naive.rs +++ b/examples/abc057-b-naive.rs @@ -7,15 +7,9 @@ fn main() { io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); macro_rules! read { - ([$tt:tt; $n:expr]) => { - (0..$n).map(|_| read!($tt)).collect::>() - }; - (($($tt:tt),+)) => { - ($(read!($tt)),*) - }; - ($ty:ty) => { - input.next().unwrap().parse::<$ty>().unwrap() - }; + ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; + (($($tt:tt),+)) => { ($(read!($tt)),*) }; + ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; } let (n, m) = read!((usize, usize)); diff --git a/examples/abc084-d.rs b/examples/abc084-d.rs index 9aa11b8..5d57b7b 100644 --- a/examples/abc084-d.rs +++ b/examples/abc084-d.rs @@ -10,19 +10,13 @@ fn main() { io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); macro_rules! read { - ([$tt:tt; $n:expr]) => { - (0..$n).map(|_| read!($tt)).collect::>() - }; - (($($tt:tt),+)) => { - ($(read!($tt)),*) - }; - ($ty:ty) => { - input.next().unwrap().parse::<$ty>().unwrap() - }; + ([$tt:tt]) => { read!([$tt; read!(usize)]) }; + ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; + (($($tt:tt),+)) => { ($(read!($tt)),*) }; + ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; } - let q = read!(usize); - let lrs = read!([(usize, usize); q]); + let lrs = read!([(usize, usize)]); let max = lrs.iter().map(|&(_, r)| r).max().unwrap(); let sieve = Sieve::new(max); diff --git a/examples/abc118-b-naive.rs b/examples/abc118-b-naive.rs index 1cd1e39..d79c646 100644 --- a/examples/abc118-b-naive.rs +++ b/examples/abc118-b-naive.rs @@ -8,24 +8,15 @@ fn main() { io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); macro_rules! read { - ([$tt:tt; $n:expr]) => { - (0..$n).map(|_| read!($tt)).collect::>() - }; - (($($tt:tt),+)) => { - ($(read!($tt)),*) - }; - (_1based) => { - read!(usize) - 1 - }; - ($ty:ty) => { - input.next().unwrap().parse::<$ty>().unwrap() - }; + ([$tt:tt]) => { read!([$tt; read!(usize)]) }; + ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; + (($($tt:tt),+)) => { ($(read!($tt)),*) }; + (_1based) => { read!(usize) - 1 }; + ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; } let (n, _) = read!((usize, usize)); - let a = (0..n) - .map(|_| read!([_1based; read!(usize)])) - .collect::>(); + let a = read!([[_1based]; n]); let ans = a .into_iter() diff --git a/examples/abc120-d.rs b/examples/abc120-d.rs index 8425a07..6ce77b9 100644 --- a/examples/abc120-d.rs +++ b/examples/abc120-d.rs @@ -9,31 +9,24 @@ fn main() { io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); macro_rules! read { - ([$tt:tt; $n:expr]) => { - (0..$n).map(|_| read!($tt)).collect::>() - }; - (($($tt:tt),+)) => { - ($(read!($tt)),*) - }; - (_1based) => { - read!(usize) - 1 - }; - ($ty:ty) => { - input.next().unwrap().parse::<$ty>().unwrap() - }; + ([$tt:tt]) => { read!([$tt; read!(usize)]) }; + ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; + (($($tt:tt),+)) => { ($(read!($tt)),*) }; + (_1based) => { read!(usize) - 1 }; + ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; } - let (n, m) = read!((usize, usize)); - let abs = read!([(_1based, _1based); m]); + let n = read!(usize); + let abs = read!([(_1based, _1based)]); let max = n * (n - 1) / 2; let mut uf = QuickFindUf::::new(n); let mut ans_rev = vec![max]; ans_rev.extend(abs.into_iter().rev().scan(max, |cur, (a, b)| { - let p = uf.get(a).size() * uf.get(b).size(); + let prod = uf.get(a).size() * uf.get(b).size(); if uf.union(a, b) { - *cur -= p; + *cur -= prod; } Some(*cur) })); diff --git a/examples/abc121-b-naive.rs b/examples/abc121-b-naive.rs index 951e19d..1f9aecb 100644 --- a/examples/abc121-b-naive.rs +++ b/examples/abc121-b-naive.rs @@ -8,15 +8,9 @@ fn main() { io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); macro_rules! read { - ([$tt:tt; $n:expr]) => { - (0..$n).map(|_| read!($tt)).collect::>() - }; - (($($tt:tt),+)) => { - ($(read!($tt)),*) - }; - ($ty:ty) => { - input.next().unwrap().parse::<$ty>().unwrap() - }; + ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; + (($($tt:tt),+)) => { ($(read!($tt)),*) }; + ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; } let (n, m, c) = read!((usize, usize, i32)); diff --git a/examples/abc150-d.rs b/examples/abc150-d.rs index bcc7f71..086897a 100644 --- a/examples/abc150-d.rs +++ b/examples/abc150-d.rs @@ -9,15 +9,9 @@ fn main() { io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); macro_rules! read { - ([$tt:tt; $n:expr]) => { - (0..$n).map(|_| read!($tt)).collect::>() - }; - (($($tt:tt),+)) => { - ($(read!($tt)),*) - }; - ($ty:ty) => { - input.next().unwrap().parse::<$ty>().unwrap() - }; + ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; + (($($tt:tt),+)) => { ($(read!($tt)),*) }; + ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; } let (n, m) = read!((usize, usize)); diff --git a/examples/apg4b-ex25.rs b/examples/apg4b-ex25.rs index 369d5f4..74aabfa 100644 --- a/examples/apg4b-ex25.rs +++ b/examples/apg4b-ex25.rs @@ -1,29 +1,24 @@ // https://atcoder.jp/contests/APG4b/tasks/APG4b_bx -#![allow(clippy::many_single_char_names)] - use fixedbitset::FixedBitSet; use itertools::Itertools as _; use std::io::{self, Read as _}; +#[allow(clippy::many_single_char_names)] fn main() { let mut input = "".to_owned(); io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); + #[rustfmt::skip] macro_rules! read { - ([$tt:tt; $n:expr]) => { - (0..$n).map(|_| read!($tt)).collect::>() - }; - ($ty:ty) => { - input.next().unwrap().parse::<$ty>().unwrap() - }; + ([$tt:tt]) => { read!([$tt; read!(usize)]) }; + ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; + ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; } - let n = read!(usize); - let a = read!([usize; n]); - let m = read!(usize); - let b = read!([usize; m]); + let a = read!([usize]); + let b = read!([usize]); let arg0 = read!(String); let args = read!([usize; if arg0 == "subtract" { 1 } else { 0 }]); diff --git a/examples/arc065-c.rs b/examples/arc065-c.rs index 61c7395..52599e2 100644 --- a/examples/arc065-c.rs +++ b/examples/arc065-c.rs @@ -8,8 +8,14 @@ use std::io::{self, Read as _}; fn main() { let mut input = "".to_owned(); io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + #[rustfmt::skip] + macro_rules! read { + (_bytes) => { read!(String).into_bytes() }; + ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; + } - let s = input.trim_end().as_bytes().to_owned(); + let s = read!(_bytes); lazy_static! { static ref R: Regex = Regex::new(r"\A(dream(er)?|eraser?)*\z").unwrap(); diff --git a/examples/arc084-c.rs b/examples/arc084-c.rs index 0936d67..9076120 100644 --- a/examples/arc084-c.rs +++ b/examples/arc084-c.rs @@ -9,15 +9,9 @@ fn main() { io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); macro_rules! read { - ([$tt:tt; $n:expr]) => { - (0..$n).map(|_| read!($tt)).collect::>() - }; - (($($tt:tt),+)) => { - ($(read!($tt)),*) - }; - ($ty:ty) => { - input.next().unwrap().parse::<$ty>().unwrap() - }; + ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; + (($($tt:tt),+)) => { ($(read!($tt)),*) }; + ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; } let n = read!(usize); diff --git a/examples/atc001-b.rs b/examples/atc001-b.rs index ff4ccf2..5fb8e15 100644 --- a/examples/atc001-b.rs +++ b/examples/atc001-b.rs @@ -9,19 +9,14 @@ fn main() { io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); macro_rules! read { - ([$tt:tt; $n:expr]) => { - (0..$n).map(|_| read!($tt)).collect::>() - }; - (($($tt:tt),+)) => { - ($(read!($tt)),*) - }; - ($ty:ty) => { - input.next().unwrap().parse::<$ty>().unwrap() - }; + ([$tt:tt]) => { read!([$tt; read!(usize)]) }; + ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; + (($($tt:tt),+)) => { ($(read!($tt)),*) }; + ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; } - let (n, q) = read!((usize, usize)); - let pabs = read!([(u8, usize, usize); q]); + let n = read!(usize); + let pabs = read!([(u8, usize, usize)]); let mut uf = UnionFind::new(n); buf_print(|stdout| { From 61618c096df7d5734f8de0dfd9d46df54f0270dc Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Tue, 14 Jan 2020 22:45:49 +0900 Subject: [PATCH 24/39] Add dead arms again --- examples/abc054-c.rs | 2 +- examples/abc057-b-naive.rs | 1 + examples/abc118-b-naive.rs | 2 +- examples/abc120-d.rs | 2 +- examples/abc121-b-naive.rs | 1 + examples/abc150-d.rs | 1 + examples/abc151-d.rs | 10 ++++------ examples/apg4b-ex25.rs | 2 +- examples/arc065-c.rs | 8 +++++--- examples/arc084-c.rs | 1 + 10 files changed, 17 insertions(+), 13 deletions(-) diff --git a/examples/abc054-c.rs b/examples/abc054-c.rs index 6f7a15e..fadf663 100644 --- a/examples/abc054-c.rs +++ b/examples/abc054-c.rs @@ -9,10 +9,10 @@ fn main() { io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); macro_rules! read { + (_1based) => { read!(usize) - 1 }; ([$tt:tt]) => { read!([$tt; read!(usize)]) }; ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; (($($tt:tt),+)) => { ($(read!($tt)),*) }; - (_1based) => { read!(usize) - 1 }; ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; } diff --git a/examples/abc057-b-naive.rs b/examples/abc057-b-naive.rs index 3e96f69..5ccb551 100644 --- a/examples/abc057-b-naive.rs +++ b/examples/abc057-b-naive.rs @@ -7,6 +7,7 @@ fn main() { io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); macro_rules! read { + ([$tt:tt]) => { read!([$tt; read!(usize)]) }; ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; (($($tt:tt),+)) => { ($(read!($tt)),*) }; ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; diff --git a/examples/abc118-b-naive.rs b/examples/abc118-b-naive.rs index d79c646..1fb81a3 100644 --- a/examples/abc118-b-naive.rs +++ b/examples/abc118-b-naive.rs @@ -8,10 +8,10 @@ fn main() { io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); macro_rules! read { + (_1based) => { read!(usize) - 1 }; ([$tt:tt]) => { read!([$tt; read!(usize)]) }; ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; (($($tt:tt),+)) => { ($(read!($tt)),*) }; - (_1based) => { read!(usize) - 1 }; ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; } diff --git a/examples/abc120-d.rs b/examples/abc120-d.rs index 6ce77b9..a56b442 100644 --- a/examples/abc120-d.rs +++ b/examples/abc120-d.rs @@ -9,10 +9,10 @@ fn main() { io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); macro_rules! read { + (_1based) => { read!(usize) - 1 }; ([$tt:tt]) => { read!([$tt; read!(usize)]) }; ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; (($($tt:tt),+)) => { ($(read!($tt)),*) }; - (_1based) => { read!(usize) - 1 }; ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; } diff --git a/examples/abc121-b-naive.rs b/examples/abc121-b-naive.rs index 1f9aecb..9493bea 100644 --- a/examples/abc121-b-naive.rs +++ b/examples/abc121-b-naive.rs @@ -8,6 +8,7 @@ fn main() { io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); macro_rules! read { + ([$tt:tt]) => { read!([$tt; read!(usize)]) }; ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; (($($tt:tt),+)) => { ($(read!($tt)),*) }; ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; diff --git a/examples/abc150-d.rs b/examples/abc150-d.rs index 086897a..f130da6 100644 --- a/examples/abc150-d.rs +++ b/examples/abc150-d.rs @@ -9,6 +9,7 @@ fn main() { io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); macro_rules! read { + ([$tt:tt]) => { read!([$tt; read!(usize)]) }; ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; (($($tt:tt),+)) => { ($(read!($tt)),*) }; ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; diff --git a/examples/abc151-d.rs b/examples/abc151-d.rs index c4eb931..72c90ac 100644 --- a/examples/abc151-d.rs +++ b/examples/abc151-d.rs @@ -12,9 +12,6 @@ fn main() { io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); macro_rules! read { - (($($tt:tt),+)) => { - ($(read!($tt)),*) - }; (_maze<$c:literal, ($h:expr, $w:expr)>) => { Array::from_shape_vec( ($h, $w), @@ -26,9 +23,10 @@ fn main() { ) .unwrap() }; - ($ty:ty) => { - input.next().unwrap().parse::<$ty>().unwrap() - }; + ([$tt:tt]) => { read!([$tt; read!(usize)]) }; + ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; + (($($tt:tt),+)) => { ($(read!($tt)),*) }; + ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; } let (h, w) = read!((usize, usize)); diff --git a/examples/apg4b-ex25.rs b/examples/apg4b-ex25.rs index 74aabfa..bba58ea 100644 --- a/examples/apg4b-ex25.rs +++ b/examples/apg4b-ex25.rs @@ -10,10 +10,10 @@ fn main() { let mut input = "".to_owned(); io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); - #[rustfmt::skip] macro_rules! read { ([$tt:tt]) => { read!([$tt; read!(usize)]) }; ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; + (($($tt:tt),+)) => { ($(read!($tt)),*) }; ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; } diff --git a/examples/arc065-c.rs b/examples/arc065-c.rs index 52599e2..1c1059f 100644 --- a/examples/arc065-c.rs +++ b/examples/arc065-c.rs @@ -9,10 +9,12 @@ fn main() { let mut input = "".to_owned(); io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); - #[rustfmt::skip] macro_rules! read { - (_bytes) => { read!(String).into_bytes() }; - ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; + (_bytes) => { read!(String).into_bytes() }; + ([$tt:tt]) => { read!([$tt; read!(usize)]) }; + ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; + (($($tt:tt),+)) => { ($(read!($tt)),*) }; + ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; } let s = read!(_bytes); diff --git a/examples/arc084-c.rs b/examples/arc084-c.rs index 9076120..269b222 100644 --- a/examples/arc084-c.rs +++ b/examples/arc084-c.rs @@ -9,6 +9,7 @@ fn main() { io::stdin().read_to_string(&mut input).unwrap(); let mut input = input.split_whitespace(); macro_rules! read { + ([$tt:tt]) => { read!([$tt; read!(usize)]) }; ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; (($($tt:tt),+)) => { ($(read!($tt)),*) }; ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; From e80232e38fa42d82de857dfe84e64f43a73da3b6 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Wed, 15 Jan 2020 00:07:20 +0900 Subject: [PATCH 25/39] `leak` strings to carve out to functions --- examples/abc054-c.rs | 12 ++++++++---- examples/abc057-b-naive.rs | 12 ++++++++---- examples/abc084-d.rs | 12 ++++++++---- examples/abc118-b-naive.rs | 12 ++++++++---- examples/abc120-d.rs | 12 ++++++++---- examples/abc121-b-naive.rs | 12 ++++++++---- examples/abc129-f.rs | 12 ++++++++---- examples/abc142-d.rs | 12 ++++++++---- examples/abc144-d.rs | 12 ++++++++---- examples/abc150-d.rs | 12 ++++++++---- examples/abc151-d.rs | 12 ++++++++---- examples/apg4b-ex25.rs | 13 ++++++++----- examples/apg4b-ex26.rs | 12 ++++++++---- examples/arc065-c.rs | 12 ++++++++---- examples/arc084-c.rs | 12 ++++++++---- examples/atc001-b.rs | 12 ++++++++---- examples/atc002-b.rs | 12 ++++++++---- examples/sumitrust2019-c.rs | 12 ++++++++---- 18 files changed, 144 insertions(+), 73 deletions(-) diff --git a/examples/abc054-c.rs b/examples/abc054-c.rs index fadf663..fb59452 100644 --- a/examples/abc054-c.rs +++ b/examples/abc054-c.rs @@ -2,12 +2,10 @@ use petgraph::matrix_graph::UnMatrix; -use std::io::{self, Read as _}; +use std::io::{self, Read}; fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); - let mut input = input.split_whitespace(); + let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { (_1based) => { read!(usize) - 1 }; ([$tt:tt]) => { read!([$tt; read!(usize)]) }; @@ -29,3 +27,9 @@ fn main() { }); println!("{}", ans); } + +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} diff --git a/examples/abc057-b-naive.rs b/examples/abc057-b-naive.rs index 5ccb551..4b9bdc3 100644 --- a/examples/abc057-b-naive.rs +++ b/examples/abc057-b-naive.rs @@ -1,11 +1,9 @@ // https://atcoder.jp/contests/abc057/tasks/abc057_b -use std::io::{self, Read as _}; +use std::io::{self, Read}; fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); - let mut input = input.split_whitespace(); + let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { ([$tt:tt]) => { read!([$tt; read!(usize)]) }; ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; @@ -26,3 +24,9 @@ fn main() { println!("{}", j + 1); } } + +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} diff --git a/examples/abc084-d.rs b/examples/abc084-d.rs index 5d57b7b..7f3be68 100644 --- a/examples/abc084-d.rs +++ b/examples/abc084-d.rs @@ -3,12 +3,10 @@ use itertools_num::ItertoolsNum as _; use primal::Sieve; -use std::io::{self, BufWriter, Read as _, StdoutLock, Write as _}; +use std::io::{self, BufWriter, Read, StdoutLock, Write as _}; fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); - let mut input = input.split_whitespace(); + let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { ([$tt:tt]) => { read!([$tt; read!(usize)]) }; ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; @@ -34,6 +32,12 @@ fn main() { }); } +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} + fn buf_print(f: impl FnOnce(&mut BufWriter)) { let stdout = io::stdout(); let mut stdout = BufWriter::new(stdout.lock()); diff --git a/examples/abc118-b-naive.rs b/examples/abc118-b-naive.rs index 1fb81a3..d068859 100644 --- a/examples/abc118-b-naive.rs +++ b/examples/abc118-b-naive.rs @@ -1,12 +1,10 @@ // https://atcoder.jp/contests/abc118/tasks/abc118_b -use std::io::{self, Read as _}; +use std::io::{self, Read}; use std::ops::{BitAnd, BitOr}; fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); - let mut input = input.split_whitespace(); + let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { (_1based) => { read!(usize) - 1 }; ([$tt:tt]) => { read!([$tt; read!(usize)]) }; @@ -25,3 +23,9 @@ fn main() { .count_ones(); println!("{}", ans); } + +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} diff --git a/examples/abc120-d.rs b/examples/abc120-d.rs index a56b442..b436377 100644 --- a/examples/abc120-d.rs +++ b/examples/abc120-d.rs @@ -2,12 +2,10 @@ use union_find::{QuickFindUf, UnionBySize, UnionFind as _}; -use std::io::{self, BufWriter, Read as _, StdoutLock, Write as _}; +use std::io::{self, BufWriter, Read, StdoutLock, Write as _}; fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); - let mut input = input.split_whitespace(); + let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { (_1based) => { read!(usize) - 1 }; ([$tt:tt]) => { read!([$tt; read!(usize)]) }; @@ -41,6 +39,12 @@ fn main() { }); } +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} + fn buf_print(f: impl FnOnce(&mut BufWriter)) { let stdout = io::stdout(); let mut stdout = BufWriter::new(stdout.lock()); diff --git a/examples/abc121-b-naive.rs b/examples/abc121-b-naive.rs index 9493bea..d167510 100644 --- a/examples/abc121-b-naive.rs +++ b/examples/abc121-b-naive.rs @@ -1,12 +1,10 @@ // https://atcoder.jp/contests/abc121/tasks/abc121_b -use std::io::{self, Read as _}; +use std::io::{self, Read}; #[allow(clippy::many_single_char_names)] fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); - let mut input = input.split_whitespace(); + let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { ([$tt:tt]) => { read!([$tt; read!(usize)]) }; ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; @@ -23,3 +21,9 @@ fn main() { .count(); println!("{}", ans); } + +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} diff --git a/examples/abc129-f.rs b/examples/abc129-f.rs index 6f5b9eb..72d68a8 100644 --- a/examples/abc129-f.rs +++ b/examples/abc129-f.rs @@ -8,13 +8,11 @@ use num_derive::{One, Zero}; use std::cell::Cell; use std::cmp; -use std::io::{self, Read as _}; +use std::io::{self, Read}; use std::ops::{Add, Div, Mul, Sub}; fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); - let mut input = input.split_whitespace(); + let mut input = read_to_static(io::stdin()).split_whitespace(); defmac!(read => input.next().unwrap().parse().unwrap()); let (l, a, b, m): (u64, u64, u64, u64) = (read!(), read!(), read!(), read!()); @@ -102,3 +100,9 @@ impl Div for Z { unreachable!("should not be performed") } } + +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} diff --git a/examples/abc142-d.rs b/examples/abc142-d.rs index feb0953..a185e5e 100644 --- a/examples/abc142-d.rs +++ b/examples/abc142-d.rs @@ -5,12 +5,10 @@ use primal::Sieve; use std::cmp::max; use std::collections::HashSet; -use std::io::{self, Read as _}; +use std::io::{self, Read}; fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); - let mut input = input.split_whitespace(); + let mut input = read_to_static(io::stdin()).split_whitespace(); defmac!(read => input.next().unwrap().parse().unwrap()); let (a, b): (usize, usize) = (read!(), read!()); @@ -26,3 +24,9 @@ fn main() { }; println!("{}", (&bases(a) & &bases(b)).len() + 1); } + +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} diff --git a/examples/abc144-d.rs b/examples/abc144-d.rs index 699fdb4..428d36a 100644 --- a/examples/abc144-d.rs +++ b/examples/abc144-d.rs @@ -3,12 +3,10 @@ use defmac::defmac; use std::f64::consts::PI; -use std::io::{self, Read as _}; +use std::io::{self, Read}; fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); - let mut input = input.split_whitespace(); + let mut input = read_to_static(io::stdin()).split_whitespace(); defmac!(read => input.next().unwrap().parse().unwrap()); let (a, b, x): (f64, f64, f64) = (read!(), read!(), read!()); @@ -21,3 +19,9 @@ fn main() { }; println!("{}", ans); } + +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} diff --git a/examples/abc150-d.rs b/examples/abc150-d.rs index f130da6..f621e70 100644 --- a/examples/abc150-d.rs +++ b/examples/abc150-d.rs @@ -2,12 +2,10 @@ use itertools::Itertools as _; -use std::io::{self, Read as _}; +use std::io::{self, Read}; fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); - let mut input = input.split_whitespace(); + let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { ([$tt:tt]) => { read!([$tt; read!(usize)]) }; ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; @@ -27,3 +25,9 @@ fn main() { let ans = (m + x0) / (2 * x0); println!("{}", ans); } + +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} diff --git a/examples/abc151-d.rs b/examples/abc151-d.rs index 72c90ac..d6800ee 100644 --- a/examples/abc151-d.rs +++ b/examples/abc151-d.rs @@ -4,13 +4,11 @@ use ndarray::Array; use smallvec::{smallvec, SmallVec}; use std::collections::VecDeque; -use std::io::{self, Read as _}; +use std::io::{self, Read}; use std::iter; fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); - let mut input = input.split_whitespace(); + let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { (_maze<$c:literal, ($h:expr, $w:expr)>) => { Array::from_shape_vec( @@ -72,3 +70,9 @@ fn main() { .unwrap(); println!("{}", ans); } + +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} diff --git a/examples/apg4b-ex25.rs b/examples/apg4b-ex25.rs index bba58ea..c83c730 100644 --- a/examples/apg4b-ex25.rs +++ b/examples/apg4b-ex25.rs @@ -3,13 +3,11 @@ use fixedbitset::FixedBitSet; use itertools::Itertools as _; -use std::io::{self, Read as _}; +use std::io::{self, Read}; #[allow(clippy::many_single_char_names)] fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); - let mut input = input.split_whitespace(); + let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { ([$tt:tt]) => { read!([$tt; read!(usize)]) }; ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; @@ -52,7 +50,6 @@ fn symmetric_diff(a: &FixedBitSet, b: &FixedBitSet) -> FixedBitSet { } fn subtract(mut a: FixedBitSet, x: usize) -> FixedBitSet { - // > xは存在することが保証される。 a.set(x, false); a } @@ -64,3 +61,9 @@ fn increment(a: &FixedBitSet) -> FixedBitSet { fn decrement(a: &FixedBitSet) -> FixedBitSet { a.ones().map(|x| (x + 49) % 50).collect() } + +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} diff --git a/examples/apg4b-ex26.rs b/examples/apg4b-ex26.rs index ecc0c9a..09c8cb7 100644 --- a/examples/apg4b-ex26.rs +++ b/examples/apg4b-ex26.rs @@ -5,14 +5,12 @@ use maplit::hashmap; use matches::matches; use std::collections::HashMap; -use std::io::{self, Read as _}; +use std::io::{self, Read}; use std::str::FromStr; fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); let mut env = hashmap!(); - for line in input.lines().skip(1) { + for line in read_to_static(io::stdin()).lines().skip(1) { line.parse::().unwrap().eval(&mut env); } } @@ -233,3 +231,9 @@ impl VecExpr { } } } + +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} diff --git a/examples/arc065-c.rs b/examples/arc065-c.rs index 1c1059f..29ba070 100644 --- a/examples/arc065-c.rs +++ b/examples/arc065-c.rs @@ -3,12 +3,10 @@ use lazy_static::lazy_static; use regex::bytes::Regex; -use std::io::{self, Read as _}; +use std::io::{self, Read}; fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); - let mut input = input.split_whitespace(); + let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { (_bytes) => { read!(String).into_bytes() }; ([$tt:tt]) => { read!([$tt; read!(usize)]) }; @@ -24,3 +22,9 @@ fn main() { }; println!("{}", if R.is_match(&s) { "YES" } else { "NO" }); } + +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} diff --git a/examples/arc084-c.rs b/examples/arc084-c.rs index 269b222..074a43f 100644 --- a/examples/arc084-c.rs +++ b/examples/arc084-c.rs @@ -2,12 +2,10 @@ use superslice::Ext as _; -use std::io::{self, Read as _}; +use std::io::{self, Read}; fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); - let mut input = input.split_whitespace(); + let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { ([$tt:tt]) => { read!([$tt; read!(usize)]) }; ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; @@ -26,3 +24,9 @@ fn main() { .sum::(); println!("{}", ans); } + +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} diff --git a/examples/atc001-b.rs b/examples/atc001-b.rs index 5fb8e15..d4941d6 100644 --- a/examples/atc001-b.rs +++ b/examples/atc001-b.rs @@ -2,12 +2,10 @@ use petgraph::unionfind::UnionFind; -use std::io::{self, BufWriter, Read as _, StdoutLock, Write as _}; +use std::io::{self, BufWriter, Read, StdoutLock, Write as _}; fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); - let mut input = input.split_whitespace(); + let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { ([$tt:tt]) => { read!([$tt; read!(usize)]) }; ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; @@ -33,6 +31,12 @@ fn main() { }); } +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} + fn buf_print(f: impl FnOnce(&mut BufWriter)) { let stdout = io::stdout(); let mut stdout = BufWriter::new(stdout.lock()); diff --git a/examples/atc002-b.rs b/examples/atc002-b.rs index 741dc70..d79bc39 100644 --- a/examples/atc002-b.rs +++ b/examples/atc002-b.rs @@ -3,15 +3,19 @@ use defmac::defmac; use num::BigUint; -use std::io::{self, Read as _}; +use std::io::{self, Read}; fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); - let mut input = input.split_whitespace(); + let mut input = read_to_static(io::stdin()).split_whitespace(); defmac!(read => input.next().unwrap().parse().unwrap()); let (n, m, p): (BigUint, BigUint, BigUint) = (read!(), read!(), read!()); println!("{}", n.modpow(&p, &m)); } + +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} diff --git a/examples/sumitrust2019-c.rs b/examples/sumitrust2019-c.rs index cd9d5fd..5453aa3 100644 --- a/examples/sumitrust2019-c.rs +++ b/examples/sumitrust2019-c.rs @@ -3,12 +3,10 @@ use defmac::defmac; use fixedbitset::FixedBitSet; -use std::io::{self, Read as _}; +use std::io::{self, Read}; fn main() { - let mut input = "".to_owned(); - io::stdin().read_to_string(&mut input).unwrap(); - let mut input = input.split_whitespace(); + let mut input = read_to_static(io::stdin()).split_whitespace(); defmac!(read => input.next().unwrap().parse().unwrap()); let x: usize = read!(); @@ -23,3 +21,9 @@ fn main() { } println!("{}", u32::from(dp[x])); } + +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} From 257923104a92f589bd2423e5ceca590eb134fc43 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Wed, 15 Jan 2020 16:37:39 +0900 Subject: [PATCH 26/39] 'MacroTranscriber' can be `(..)` --- examples/abc054-c.rs | 12 +++++++----- examples/abc057-b-naive.rs | 8 ++++---- examples/abc084-d.rs | 10 +++++----- examples/abc118-b-naive.rs | 12 +++++++----- examples/abc120-d.rs | 14 ++++++++------ examples/abc121-b-naive.rs | 8 ++++---- examples/abc150-d.rs | 8 ++++---- examples/abc151-d.rs | 8 ++++---- examples/apg4b-ex25.rs | 8 ++++---- examples/arc065-c.rs | 12 +++++++----- examples/arc084-c.rs | 8 ++++---- examples/atc001-b.rs | 10 +++++----- 12 files changed, 63 insertions(+), 55 deletions(-) diff --git a/examples/abc054-c.rs b/examples/abc054-c.rs index fb59452..dab221c 100644 --- a/examples/abc054-c.rs +++ b/examples/abc054-c.rs @@ -7,11 +7,13 @@ use std::io::{self, Read}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { - (_1based) => { read!(usize) - 1 }; - ([$tt:tt]) => { read!([$tt; read!(usize)]) }; - ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; - (($($tt:tt),+)) => { ($(read!($tt)),*) }; - ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; + (_1based) => { + read!(usize) - 1 + }; + ([$tt:tt]) => (read!([$tt; read!(usize)])); + ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); + (($($tt:tt),+)) => (($(read!($tt)),*)); + ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); } let n = read!(usize); diff --git a/examples/abc057-b-naive.rs b/examples/abc057-b-naive.rs index 4b9bdc3..fc85f3d 100644 --- a/examples/abc057-b-naive.rs +++ b/examples/abc057-b-naive.rs @@ -5,10 +5,10 @@ use std::io::{self, Read}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { - ([$tt:tt]) => { read!([$tt; read!(usize)]) }; - ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; - (($($tt:tt),+)) => { ($(read!($tt)),*) }; - ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; + ([$tt:tt]) => (read!([$tt; read!(usize)])); + ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); + (($($tt:tt),+)) => (($(read!($tt)),*)); + ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); } let (n, m) = read!((usize, usize)); diff --git a/examples/abc084-d.rs b/examples/abc084-d.rs index 7f3be68..318d167 100644 --- a/examples/abc084-d.rs +++ b/examples/abc084-d.rs @@ -8,10 +8,10 @@ use std::io::{self, BufWriter, Read, StdoutLock, Write as _}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { - ([$tt:tt]) => { read!([$tt; read!(usize)]) }; - ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; - (($($tt:tt),+)) => { ($(read!($tt)),*) }; - ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; + ([$tt:tt]) => (read!([$tt; read!(usize)])); + ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); + (($($tt:tt),+)) => (($(read!($tt)),*)); + ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); } let lrs = read!([(usize, usize)]); @@ -24,7 +24,7 @@ fn main() { .collect::>(); buf_print(|stdout| { - macro_rules! println { ($($tt:tt)*) => { writeln!(stdout, $($tt)*).unwrap() }; } + macro_rules! println(($($tt:tt)*) => (writeln!(stdout, $($tt)*).unwrap())); for (l, r) in lrs { println!("{}", nums[r] - nums[l - 1]); diff --git a/examples/abc118-b-naive.rs b/examples/abc118-b-naive.rs index d068859..5973826 100644 --- a/examples/abc118-b-naive.rs +++ b/examples/abc118-b-naive.rs @@ -6,11 +6,13 @@ use std::ops::{BitAnd, BitOr}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { - (_1based) => { read!(usize) - 1 }; - ([$tt:tt]) => { read!([$tt; read!(usize)]) }; - ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; - (($($tt:tt),+)) => { ($(read!($tt)),*) }; - ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; + (_1based) => { + read!(usize) - 1 + }; + ([$tt:tt]) => (read!([$tt; read!(usize)])); + ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); + (($($tt:tt),+)) => (($(read!($tt)),*)); + ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); } let (n, _) = read!((usize, usize)); diff --git a/examples/abc120-d.rs b/examples/abc120-d.rs index b436377..81b8ea2 100644 --- a/examples/abc120-d.rs +++ b/examples/abc120-d.rs @@ -7,11 +7,13 @@ use std::io::{self, BufWriter, Read, StdoutLock, Write as _}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { - (_1based) => { read!(usize) - 1 }; - ([$tt:tt]) => { read!([$tt; read!(usize)]) }; - ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; - (($($tt:tt),+)) => { ($(read!($tt)),*) }; - ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; + (_1based) => { + read!(usize) - 1 + }; + ([$tt:tt]) => (read!([$tt; read!(usize)])); + ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); + (($($tt:tt),+)) => (($(read!($tt)),*)); + ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); } let n = read!(usize); @@ -31,7 +33,7 @@ fn main() { assert_eq!(ans_rev.pop(), Some(0)); buf_print(|stdout| { - macro_rules! println { ($($tt:tt)*) => { writeln!(stdout, $($tt)*).unwrap() }; } + macro_rules! println(($($tt:tt)*) => (writeln!(stdout, $($tt)*).unwrap())); for x in ans_rev.into_iter().rev() { println!("{}", x); diff --git a/examples/abc121-b-naive.rs b/examples/abc121-b-naive.rs index d167510..33b4177 100644 --- a/examples/abc121-b-naive.rs +++ b/examples/abc121-b-naive.rs @@ -6,10 +6,10 @@ use std::io::{self, Read}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { - ([$tt:tt]) => { read!([$tt; read!(usize)]) }; - ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; - (($($tt:tt),+)) => { ($(read!($tt)),*) }; - ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; + ([$tt:tt]) => (read!([$tt; read!(usize)])); + ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); + (($($tt:tt),+)) => (($(read!($tt)),*)); + ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); } let (n, m, c) = read!((usize, usize, i32)); diff --git a/examples/abc150-d.rs b/examples/abc150-d.rs index f621e70..9925316 100644 --- a/examples/abc150-d.rs +++ b/examples/abc150-d.rs @@ -7,10 +7,10 @@ use std::io::{self, Read}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { - ([$tt:tt]) => { read!([$tt; read!(usize)]) }; - ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; - (($($tt:tt),+)) => { ($(read!($tt)),*) }; - ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; + ([$tt:tt]) => (read!([$tt; read!(usize)])); + ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); + (($($tt:tt),+)) => (($(read!($tt)),*)); + ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); } let (n, m) = read!((usize, usize)); diff --git a/examples/abc151-d.rs b/examples/abc151-d.rs index d6800ee..39c2125 100644 --- a/examples/abc151-d.rs +++ b/examples/abc151-d.rs @@ -21,10 +21,10 @@ fn main() { ) .unwrap() }; - ([$tt:tt]) => { read!([$tt; read!(usize)]) }; - ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; - (($($tt:tt),+)) => { ($(read!($tt)),*) }; - ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; + ([$tt:tt]) => (read!([$tt; read!(usize)])); + ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); + (($($tt:tt),+)) => (($(read!($tt)),*)); + ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); } let (h, w) = read!((usize, usize)); diff --git a/examples/apg4b-ex25.rs b/examples/apg4b-ex25.rs index c83c730..e68f73d 100644 --- a/examples/apg4b-ex25.rs +++ b/examples/apg4b-ex25.rs @@ -9,10 +9,10 @@ use std::io::{self, Read}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { - ([$tt:tt]) => { read!([$tt; read!(usize)]) }; - ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; - (($($tt:tt),+)) => { ($(read!($tt)),*) }; - ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; + ([$tt:tt]) => (read!([$tt; read!(usize)])); + ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); + (($($tt:tt),+)) => (($(read!($tt)),*)); + ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); } let a = read!([usize]); diff --git a/examples/arc065-c.rs b/examples/arc065-c.rs index 29ba070..cf533ed 100644 --- a/examples/arc065-c.rs +++ b/examples/arc065-c.rs @@ -8,11 +8,13 @@ use std::io::{self, Read}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { - (_bytes) => { read!(String).into_bytes() }; - ([$tt:tt]) => { read!([$tt; read!(usize)]) }; - ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; - (($($tt:tt),+)) => { ($(read!($tt)),*) }; - ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; + (_bytes) => { + read!(String).into_bytes() + }; + ([$tt:tt]) => (read!([$tt; read!(usize)])); + ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); + (($($tt:tt),+)) => (($(read!($tt)),*)); + ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); } let s = read!(_bytes); diff --git a/examples/arc084-c.rs b/examples/arc084-c.rs index 074a43f..b322de4 100644 --- a/examples/arc084-c.rs +++ b/examples/arc084-c.rs @@ -7,10 +7,10 @@ use std::io::{self, Read}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { - ([$tt:tt]) => { read!([$tt; read!(usize)]) }; - ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; - (($($tt:tt),+)) => { ($(read!($tt)),*) }; - ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; + ([$tt:tt]) => (read!([$tt; read!(usize)])); + ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); + (($($tt:tt),+)) => (($(read!($tt)),*)); + ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); } let n = read!(usize); diff --git a/examples/atc001-b.rs b/examples/atc001-b.rs index d4941d6..2c4ea57 100644 --- a/examples/atc001-b.rs +++ b/examples/atc001-b.rs @@ -7,10 +7,10 @@ use std::io::{self, BufWriter, Read, StdoutLock, Write as _}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { - ([$tt:tt]) => { read!([$tt; read!(usize)]) }; - ([$tt:tt; $n:expr]) => { (0..$n).map(|_| read!($tt)).collect::>() }; - (($($tt:tt),+)) => { ($(read!($tt)),*) }; - ($ty:ty) => { input.next().unwrap().parse::<$ty>().unwrap() }; + ([$tt:tt]) => (read!([$tt; read!(usize)])); + ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); + (($($tt:tt),+)) => (($(read!($tt)),*)); + ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); } let n = read!(usize); @@ -18,7 +18,7 @@ fn main() { let mut uf = UnionFind::new(n); buf_print(|stdout| { - macro_rules! println { ($($tt:tt)*) => { writeln!(stdout, $($tt)*).unwrap() }; } + macro_rules! println(($($tt:tt)*) => (writeln!(stdout, $($tt)*).unwrap())); for (p, a, b) in pabs { if p == 1 { From b1d122ff1940af242e8a239b552514f88845c0d5 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Wed, 15 Jan 2020 16:59:55 +0900 Subject: [PATCH 27/39] Remove 'defmac's --- examples/abc129-f.rs | 3 +-- examples/abc142-d.rs | 3 +-- examples/abc144-d.rs | 4 +--- examples/atc002-b.rs | 3 +-- examples/sumitrust2019-c.rs | 3 +-- test-with-generated-opts.toml | 10 +++++----- 6 files changed, 10 insertions(+), 16 deletions(-) diff --git a/examples/abc129-f.rs b/examples/abc129-f.rs index 72d68a8..46d43a4 100644 --- a/examples/abc129-f.rs +++ b/examples/abc129-f.rs @@ -1,6 +1,5 @@ // https://atcoder.jp/contests/abc129/tasks/abc129_f -use defmac::defmac; use derive_more::Display; use ndarray::{array, Array2, LinalgScalar}; use num::{PrimInt, Unsigned}; @@ -13,7 +12,7 @@ use std::ops::{Add, Div, Mul, Sub}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); - defmac!(read => input.next().unwrap().parse().unwrap()); + macro_rules! read(() => (input.next().unwrap().parse().unwrap())); let (l, a, b, m): (u64, u64, u64, u64) = (read!(), read!(), read!(), read!()); diff --git a/examples/abc142-d.rs b/examples/abc142-d.rs index a185e5e..ca2ffb4 100644 --- a/examples/abc142-d.rs +++ b/examples/abc142-d.rs @@ -1,6 +1,5 @@ // https://atcoder.jp/contests/abc142/tasks/abc142_d -use defmac::defmac; use primal::Sieve; use std::cmp::max; @@ -9,7 +8,7 @@ use std::io::{self, Read}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); - defmac!(read => input.next().unwrap().parse().unwrap()); + macro_rules! read(() => (input.next().unwrap().parse().unwrap())); let (a, b): (usize, usize) = (read!(), read!()); diff --git a/examples/abc144-d.rs b/examples/abc144-d.rs index 428d36a..47efb32 100644 --- a/examples/abc144-d.rs +++ b/examples/abc144-d.rs @@ -1,13 +1,11 @@ // https://atcoder.jp/contests/abc144/tasks/abc144_d -use defmac::defmac; - use std::f64::consts::PI; use std::io::{self, Read}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); - defmac!(read => input.next().unwrap().parse().unwrap()); + macro_rules! read(() => (input.next().unwrap().parse().unwrap())); let (a, b, x): (f64, f64, f64) = (read!(), read!(), read!()); diff --git a/examples/atc002-b.rs b/examples/atc002-b.rs index d79bc39..54ae0bc 100644 --- a/examples/atc002-b.rs +++ b/examples/atc002-b.rs @@ -1,13 +1,12 @@ // https://atcoder.jp/contests/atc002/tasks/atc002_b -use defmac::defmac; use num::BigUint; use std::io::{self, Read}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); - defmac!(read => input.next().unwrap().parse().unwrap()); + macro_rules! read(() => (input.next().unwrap().parse().unwrap())); let (n, m, p): (BigUint, BigUint, BigUint) = (read!(), read!(), read!()); diff --git a/examples/sumitrust2019-c.rs b/examples/sumitrust2019-c.rs index 5453aa3..e24269a 100644 --- a/examples/sumitrust2019-c.rs +++ b/examples/sumitrust2019-c.rs @@ -1,13 +1,12 @@ // https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_c -use defmac::defmac; use fixedbitset::FixedBitSet; use std::io::{self, Read}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); - defmac!(read => input.next().unwrap().parse().unwrap()); + macro_rules! read(() => (input.next().unwrap().parse().unwrap())); let x: usize = read!(); diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml index f8c7a4d..356c816 100644 --- a/test-with-generated-opts.toml +++ b/test-with-generated-opts.toml @@ -97,7 +97,7 @@ meta = { using = ["whiteread"] } name = "ABC129: F - Takahashi's Basics in Education and Learning" url = "https://atcoder.jp/contests/abc129/tasks/abc129_f" matching = "Words" -meta = { using = ["defmac", "derive_more", "ndarray", "num", "num-derive"] } +meta = { using = ["derive_more", "ndarray", "num", "num-derive"] } [examples.abc141-c] name = "ABC141: C - Attack Survival" @@ -109,13 +109,13 @@ meta = { using = ["proconio"] } name = "ABC142: D - Disjoint Set of Common Divisors" url = "https://atcoder.jp/contests/abc142/tasks/abc142_d" matching = "Words" -meta = { using = ["defmac", "num-integer", "primal"] } +meta = { using = ["num-integer", "primal"] } [examples.abc144-d] name = "ABC144: D - Water Bottle" url = "https://atcoder.jp/contests/abc144/tasks/abc144_d" matching = { FloatOr = { abs = 1e-6, rel = 1e-6 } } -meta = { using = ["defmac", "libm"] } +meta = { using = ["libm"] } [examples.abc150-d] name = "ABC150: D - Semi Common Multiple" @@ -170,10 +170,10 @@ meta = { using = ["petgraph"] } name = "ATC002: B - n^p mod m" url = "https://atcoder.jp/contests/atc002/tasks/atc002_b" matching = "Words" -meta = { using = ["defmac", "num"] } +meta = { using = ["num"] } [examples.sumitrust2019-c] name = "Sumitomo Mitsui Trust Bank Programming Contest 2019: C - 100 to 105" url = "https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_c" matching = "Words" -meta = { using = ["defmac", "fixedbitset"] } +meta = { using = ["fixedbitset"] } From 39208de41e92625a5fe6b4eca66debdde5b4c03d Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Wed, 15 Jan 2020 18:06:00 +0900 Subject: [PATCH 28/39] Add examples for practice-A --- examples/practice-a-naive.rs | 14 ++++++++++++++ examples/practice-a-proconio.rs | 14 ++++++++++++++ examples/practice-a-text-io.rs | 10 ++++++++++ examples/practice-a-whiteread.rs | 11 +++++++++++ test-with-generated-opts.toml | 28 ++++++++++++++++++++++++++++ 5 files changed, 77 insertions(+) create mode 100644 examples/practice-a-naive.rs create mode 100644 examples/practice-a-proconio.rs create mode 100644 examples/practice-a-text-io.rs create mode 100644 examples/practice-a-whiteread.rs diff --git a/examples/practice-a-naive.rs b/examples/practice-a-naive.rs new file mode 100644 index 0000000..c16b51c --- /dev/null +++ b/examples/practice-a-naive.rs @@ -0,0 +1,14 @@ +// https://atcoder.jp/contests/practice/tasks/practice_1 + +use std::io::{self, Read as _}; + +fn main() { + let mut input = "".to_owned(); + io::stdin().read_to_string(&mut input).unwrap(); + let mut input = input.split_whitespace(); + macro_rules! read(() => (input.next().unwrap().parse().unwrap())); + + let (a, b, c, s): (u32, u32, u32, String) = (read!(), read!(), read!(), read!()); + + println!("{} {}", a + b + c, s); +} diff --git a/examples/practice-a-proconio.rs b/examples/practice-a-proconio.rs new file mode 100644 index 0000000..d7b635e --- /dev/null +++ b/examples/practice-a-proconio.rs @@ -0,0 +1,14 @@ +// https://atcoder.jp/contests/practice/tasks/practice_1 + +use proconio::input; + +fn main() { + input! { + a: u32, + b: u32, + c: u32, + s: String, + } + + println!("{} {}", a + b + c, s); +} diff --git a/examples/practice-a-text-io.rs b/examples/practice-a-text-io.rs new file mode 100644 index 0000000..cc39bde --- /dev/null +++ b/examples/practice-a-text-io.rs @@ -0,0 +1,10 @@ +// https://atcoder.jp/contests/practice/tasks/practice_1 + +use text_io::{read, try_read, try_scan}; + +#[allow(clippy::many_single_char_names, clippy::try_err)] +fn main() { + let (a, b, c, s): (u32, u32, u32, String) = (read!(), read!(), read!(), read!()); + + println!("{} {}", a + b + c, s); +} diff --git a/examples/practice-a-whiteread.rs b/examples/practice-a-whiteread.rs new file mode 100644 index 0000000..16b4031 --- /dev/null +++ b/examples/practice-a-whiteread.rs @@ -0,0 +1,11 @@ +// https://atcoder.jp/contests/practice/tasks/practice_1 + +use whiteread::Reader; + +fn main() { + let mut rdr = Reader::from_stdin_naive(); + + let (a, b, c, s) = rdr.p::<(u32, u32, u32, String)>(); + + println!("{} {}", a + b + c, s); +} diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml index 356c816..5ab2017 100644 --- a/test-with-generated-opts.toml +++ b/test-with-generated-opts.toml @@ -172,6 +172,34 @@ url = "https://atcoder.jp/contests/atc002/tasks/atc002_b" matching = "Words" meta = { using = ["num"] } +[examples.practice-a-naive] +name = "practice contest: A - Welcome to AtCoder" +url = "https://atcoder.jp/contests/practice/tasks/practice_1" +matching = "Exact" +alt_testcases = [{ in = "1\n2 3\ntest", out = "6 test\n" }, { in = "72\n128 256\nmyonmyon", out = "456 myonmyon\n" }] +meta = { using = [] } # 下3つと比較するため + +[examples.practice-a-proconio] +name = "practice contest: A - Welcome to AtCoder" +url = "https://atcoder.jp/contests/practice/tasks/practice_1" +matching = "Exact" +alt_testcases = [{ in = "1\n2 3\ntest", out = "6 test\n" }, { in = "72\n128 256\nmyonmyon", out = "456 myonmyon\n" }] +meta = { using = ["proconio"] } + +[examples.practice-a-text-io] +name = "practice contest: A - Welcome to AtCoder" +url = "https://atcoder.jp/contests/practice/tasks/practice_1" +matching = "Exact" +alt_testcases = [{ in = "1\n2 3\ntest", out = "6 test\n" }, { in = "72\n128 256\nmyonmyon", out = "456 myonmyon\n" }] +meta = { using = ["text-io"] } + +[examples.practice-a-whiteread] +name = "practice contest: A - Welcome to AtCoder" +url = "https://atcoder.jp/contests/practice/tasks/practice_1" +matching = "Exact" +alt_testcases = [{ in = "1\n2 3\ntest", out = "6 test\n" }, { in = "72\n128 256\nmyonmyon", out = "456 myonmyon\n" }] +meta = { using = ["whiteread"] } + [examples.sumitrust2019-c] name = "Sumitomo Mitsui Trust Bank Programming Contest 2019: C - 100 to 105" url = "https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_c" From 3823bf1d0b522829f5ea2d67c73fdabc5c115482 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Wed, 15 Jan 2020 18:57:14 +0900 Subject: [PATCH 29/39] Modify `read!`s --- examples/abc054-c.rs | 8 ++++---- examples/abc118-b-naive.rs | 8 ++++---- examples/abc120-d.rs | 8 ++++---- examples/abc151-d.rs | 12 ++++++------ examples/arc065-c.rs | 8 ++++---- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/examples/abc054-c.rs b/examples/abc054-c.rs index dab221c..09a1435 100644 --- a/examples/abc054-c.rs +++ b/examples/abc054-c.rs @@ -7,17 +7,17 @@ use std::io::{self, Read}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { - (_1based) => { - read!(usize) - 1 - }; ([$tt:tt]) => (read!([$tt; read!(usize)])); ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); (($($tt:tt),+)) => (($(read!($tt)),*)); ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); + ({ Usize1 }) => { + read!(usize) - 1 + }; } let n = read!(usize); - let abs = read!([(_1based, _1based)]); + let abs = read!([({ Usize1 }, { Usize1 })]); let graph = UnMatrix::<(), (), Option<()>, usize>::from_edges(abs); let mut ans = 0; diff --git a/examples/abc118-b-naive.rs b/examples/abc118-b-naive.rs index 5973826..925c6fa 100644 --- a/examples/abc118-b-naive.rs +++ b/examples/abc118-b-naive.rs @@ -6,17 +6,17 @@ use std::ops::{BitAnd, BitOr}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { - (_1based) => { - read!(usize) - 1 - }; ([$tt:tt]) => (read!([$tt; read!(usize)])); ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); (($($tt:tt),+)) => (($(read!($tt)),*)); ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); + ({ Usize1 }) => { + read!(usize) - 1 + }; } let (n, _) = read!((usize, usize)); - let a = read!([[_1based]; n]); + let a = read!([[{ Usize1 }]; n]); let ans = a .into_iter() diff --git a/examples/abc120-d.rs b/examples/abc120-d.rs index 81b8ea2..20d10ad 100644 --- a/examples/abc120-d.rs +++ b/examples/abc120-d.rs @@ -7,17 +7,17 @@ use std::io::{self, BufWriter, Read, StdoutLock, Write as _}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { - (_1based) => { - read!(usize) - 1 - }; ([$tt:tt]) => (read!([$tt; read!(usize)])); ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); (($($tt:tt),+)) => (($(read!($tt)),*)); ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); + ({ Usize1 }) => { + read!(usize) - 1 + }; } let n = read!(usize); - let abs = read!([(_1based, _1based)]); + let abs = read!([({ Usize1 }, { Usize1 })]); let max = n * (n - 1) / 2; let mut uf = QuickFindUf::::new(n); diff --git a/examples/abc151-d.rs b/examples/abc151-d.rs index 39c2125..9a0c36b 100644 --- a/examples/abc151-d.rs +++ b/examples/abc151-d.rs @@ -10,7 +10,11 @@ use std::iter; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { - (_maze<$c:literal, ($h:expr, $w:expr)>) => { + ([$tt:tt]) => (read!([$tt; read!(usize)])); + ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); + (($($tt:tt),+)) => (($(read!($tt)),*)); + ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); + ({ Maze<$c:literal, ($h:expr, $w:expr)> }) => { Array::from_shape_vec( ($h, $w), (0..$h) @@ -21,14 +25,10 @@ fn main() { ) .unwrap() }; - ([$tt:tt]) => (read!([$tt; read!(usize)])); - ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); - (($($tt:tt),+)) => (($(read!($tt)),*)); - ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); } let (h, w) = read!((usize, usize)); - let maze = read!(_maze); + let maze = read!({ Maze }); let neighbors = Array::from_shape_fn((h, w), |(i, j)| -> SmallVec<[_; 4]> { let mut neighbors = smallvec![]; diff --git a/examples/arc065-c.rs b/examples/arc065-c.rs index cf533ed..3760780 100644 --- a/examples/arc065-c.rs +++ b/examples/arc065-c.rs @@ -8,16 +8,16 @@ use std::io::{self, Read}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); macro_rules! read { - (_bytes) => { - read!(String).into_bytes() - }; ([$tt:tt]) => (read!([$tt; read!(usize)])); ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); (($($tt:tt),+)) => (($(read!($tt)),*)); ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); + ({ Bytes }) => { + read!(String).into_bytes() + }; } - let s = read!(_bytes); + let s = read!({ Bytes }); lazy_static! { static ref R: Regex = Regex::new(r"\A(dream(er)?|eraser?)*\z").unwrap(); From dc9129d2deba8ac71a138fbe41d23911baf25d10 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Wed, 15 Jan 2020 19:10:24 +0900 Subject: [PATCH 30/39] Modify `abc054-c` --- examples/abc054-c.rs | 17 ++++++++--------- test-with-generated-opts.toml | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/examples/abc054-c.rs b/examples/abc054-c.rs index 09a1435..dc13738 100644 --- a/examples/abc054-c.rs +++ b/examples/abc054-c.rs @@ -1,6 +1,7 @@ // https://atcoder.jp/contests/abc054/tasks/abc054_c -use petgraph::matrix_graph::UnMatrix; +use itertools::Itertools as _; +use petgraph::graph::UnGraph; use std::io::{self, Read}; @@ -19,14 +20,12 @@ fn main() { let n = read!(usize); let abs = read!([({ Usize1 }, { Usize1 })]); - let graph = UnMatrix::<(), (), Option<()>, usize>::from_edges(abs); - let mut ans = 0; - let mut nodes = (0..n).map(Into::into).collect::>(); - permutohedron::heap_recursive(&mut nodes, |nodes| { - if nodes[0] == 0.into() && nodes.windows(2).all(|w| graph.has_edge(w[0], w[1])) { - ans += 1; - } - }); + let graph = UnGraph::<(), (), usize>::from_edges(abs); + let ans = graph + .node_indices() + .permutations(n) + .filter(|p| p[0].index() == 0 && p.windows(2).all(|w| graph.contains_edge(w[0], w[1]))) + .count(); println!("{}", ans); } diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml index 5ab2017..c979590 100644 --- a/test-with-generated-opts.toml +++ b/test-with-generated-opts.toml @@ -7,7 +7,7 @@ testcases = "./target/test-with-generated-opts/testcases/{}" name = "ABC054: C - One-stroke Path" url = "https://atcoder.jp/contests/abc054/tasks/abc054_c" matching = "Words" -meta = { using = ["permutohedron", "petgraph"] } +meta = { using = ["itertools", "petgraph"] } [examples.abc057-b-naive] name = "ABC057: B - Checkpoints" From 02e21ec6ae2701c15a40178a3334d463c5486899 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Wed, 15 Jan 2020 20:01:26 +0900 Subject: [PATCH 31/39] Add an example for ABC142-C --- examples/abc142-c.rs | 29 +++++++++++++++++++++++++++++ test-with-generated-opts.toml | 6 ++++++ 2 files changed, 35 insertions(+) create mode 100644 examples/abc142-c.rs diff --git a/examples/abc142-c.rs b/examples/abc142-c.rs new file mode 100644 index 0000000..45d2ad3 --- /dev/null +++ b/examples/abc142-c.rs @@ -0,0 +1,29 @@ +// https://atcoder.jp/contests/abc142/tasks/abc142_c + +use itertools::Itertools as _; +use superslice::Ext2 as _; + +use std::io::{self, Read}; + +fn main() { + let mut input = read_to_static(io::stdin()).split_whitespace(); + macro_rules! read { + ([$tt:tt]) => (read!([$tt; read!(usize)])); + ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); + (($($tt:tt),+)) => (($(read!($tt)),*)); + ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); + ({ Isize1 }) => { + read!(isize) - 1 + }; + } + + let mut a = read!([{ Isize1 }]); + a.invert_permutation(); + println!("{}", a.iter().map(|a| a + 1).format(" ")); +} + +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml index c979590..e0c33d1 100644 --- a/test-with-generated-opts.toml +++ b/test-with-generated-opts.toml @@ -105,6 +105,12 @@ url = "https://atcoder.jp/contests/abc141/tasks/abc141_c" matching = "Words" meta = { using = ["proconio"] } +[examples.abc142-c] +name = "ABC142: C - Go to School" +url = "https://atcoder.jp/contests/abc142/tasks/abc142_c" +matching = "Words" +meta = { using = ["itertools", "superslice"] } + [examples.abc142-d] name = "ABC142: D - Disjoint Set of Common Divisors" url = "https://atcoder.jp/contests/abc142/tasks/abc142_d" From 180ad350ae08c401d6007596d0b547a6a1a6d3c9 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Wed, 15 Jan 2020 20:50:14 +0900 Subject: [PATCH 32/39] Add an example for ABC073-D --- examples/abc073-d.rs | 48 +++++++++++++++++++++++++++++++++++ test-with-generated-opts.toml | 6 +++++ 2 files changed, 54 insertions(+) create mode 100644 examples/abc073-d.rs diff --git a/examples/abc073-d.rs b/examples/abc073-d.rs new file mode 100644 index 0000000..fff913d --- /dev/null +++ b/examples/abc073-d.rs @@ -0,0 +1,48 @@ +// https://atcoder.jp/contests/abc073/tasks/abc073_d + +use itertools::Itertools as _; +use petgraph::graph::{NodeIndex, UnGraph}; + +use std::collections::HashMap; +use std::io::{self, Read}; + +fn main() { + let mut input = read_to_static(io::stdin()).split_whitespace(); + macro_rules! read { + ([$tt:tt]) => (read!([$tt; read!(usize)])); + ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::>()); + (($($tt:tt),+)) => (($(read!($tt)),*)); + ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()); + ({ NodeIndex1 }) => { + NodeIndex::from(read!(u32) - 1) + }; + } + + let (_, m, r) = read!((usize, usize, usize)); + let rs = read!([{ NodeIndex1 }; r]); + let abcs = read!([({ NodeIndex1 }, { NodeIndex1 }, u32); m]); + + let graph = UnGraph::<(), u32>::from_edges(abcs); + + let dijkstra = rs + .iter() + .map(|&r| { + let dijkstra = petgraph::algo::dijkstra(&graph, r, None, |e| *e.weight()); + (r, dijkstra) + }) + .collect::>(); + + let ans = rs + .into_iter() + .permutations(r) + .map(|rs| rs.windows(2).map(|w| dijkstra[&w[0]][&w[1]]).sum::()) + .min() + .unwrap(); + println!("{}", ans); +} + +fn read_to_static(mut source: impl Read) -> &'static str { + let mut input = "".to_owned(); + source.read_to_string(&mut input).unwrap(); + Box::leak(input.into_boxed_str()) +} diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml index e0c33d1..7b36baf 100644 --- a/test-with-generated-opts.toml +++ b/test-with-generated-opts.toml @@ -33,6 +33,12 @@ url = "https://atcoder.jp/contests/abc057/tasks/abc057_b" matching = "Words" meta = { using = ["whiteread"] } +[examples.abc073-d] +name = "ABC073: D - joisino's travel" +url = "https://atcoder.jp/contests/abc073/tasks/abc073_d" +matching = "Words" +meta = { using = ["itertools", "petgraph"] } + [examples.abc084-d] name = "ABC084: D - 2017-like Number" url = "https://atcoder.jp/contests/abc084/tasks/abc084_d" From f204639b4bfdabfc94c8d2e115c44875f2be2fb5 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Thu, 16 Jan 2020 00:37:43 +0900 Subject: [PATCH 33/39] Modify `abc151-d` --- examples/abc151-d.rs | 57 +++++++++++++++++------------------ test-with-generated-opts.toml | 2 +- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/examples/abc151-d.rs b/examples/abc151-d.rs index 9a0c36b..4333a07 100644 --- a/examples/abc151-d.rs +++ b/examples/abc151-d.rs @@ -1,11 +1,10 @@ // https://atcoder.jp/contests/abc151/tasks/abc151_d use ndarray::Array; -use smallvec::{smallvec, SmallVec}; +use smallvec::SmallVec; -use std::collections::VecDeque; use std::io::{self, Read}; -use std::iter; +use std::{iter, mem}; fn main() { let mut input = read_to_static(io::stdin()).split_whitespace(); @@ -17,28 +16,28 @@ fn main() { ({ Maze<$c:literal, ($h:expr, $w:expr)> }) => { Array::from_shape_vec( ($h, $w), - (0..$h) - .fold(vec![], |mut acc, _| { - acc.extend(input.next().unwrap().bytes().map(|c| c == $c)); - acc - }), + itertools::concat((0..$h).map(|_| read!({ Row<$c> }))), ) .unwrap() }; + ({ Row<$c:literal> }) => { + read!({ Bytes }).into_iter().map(|c| c == $c).collect::>() + }; + ({ Bytes }) => { + read!(String).into_bytes() + }; } let (h, w) = read!((usize, usize)); let maze = read!({ Maze }); - let neighbors = Array::from_shape_fn((h, w), |(i, j)| -> SmallVec<[_; 4]> { - let mut neighbors = smallvec![]; - macro_rules! push { - (if $cond:expr => $pos:expr) => { - if $cond && maze[$pos] { - neighbors.push($pos); - } - }; - } + let neighbors = Array::from_shape_fn((h, w), |(i, j)| { + let mut neighbors = SmallVec::<[_; 4]>::new(); + macro_rules! push((if $cond:expr => $pos:expr) => { + if $cond && maze[$pos] { + neighbors.push($pos); + } + }); push!(if 0 < i => (i - 1, j)); push!(if i < h - 1 => (i + 1, j)); push!(if 0 < j => (i, j - 1)); @@ -50,21 +49,21 @@ fn main() { .flat_map(|i| (0..w).map(move |j| (i, j))) .filter(|&p| maze[p]) .map(|start| { - let mut longest = 0; - let mut queue = iter::once((start, 0)).collect::>(); + let mut queue = vec![start]; let mut unvisited = maze.clone(); unvisited[start] = false; - while let Some((pos, dist)) = queue.pop_front() { - for &neighbor in &neighbors[pos] { - if unvisited[neighbor] { - unvisited[neighbor] = false; - longest = dist + 1; - queue.push_back((neighbor, longest)); - } - } - } - longest + iter::repeat(()) + .take_while(|_| { + queue = queue + .iter() + .flat_map(|&p| &neighbors[p]) + .copied() + .filter(|&p| mem::replace(&mut unvisited[p], false)) + .collect(); + !queue.is_empty() + }) + .count() }) .max() .unwrap(); diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml index 7b36baf..4b7cab1 100644 --- a/test-with-generated-opts.toml +++ b/test-with-generated-opts.toml @@ -139,7 +139,7 @@ meta = { using = ["itertools", "num"] } name = "ABC151: D - Maze Master" url = "https://atcoder.jp/contests/abc151/tasks/abc151_d" matching = "Words" -meta = { using = ["ndarray", "smallvec"] } +meta = { using = ["itertools", "ndarray", "smallvec"] } [examples.apg4b-a] name = "APG4b: A - 1.00.はじめに" From 65632fe879e37f3d0eadb6be21ebacab43f1bc0f Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Fri, 17 Jan 2020 00:25:41 +0900 Subject: [PATCH 34/39] Add examples for practice-B --- examples/practice-b-naive.rs | 108 +++++++++++++++++++++++++++++++ examples/practice-b-proconio.rs | 107 ++++++++++++++++++++++++++++++ examples/practice-b-text-io.rs | 106 ++++++++++++++++++++++++++++++ examples/practice-b-whiteread.rs | 96 +++++++++++++++++++++++++++ test-with-generated-opts.toml | 20 ++++++ 5 files changed, 437 insertions(+) create mode 100644 examples/practice-b-naive.rs create mode 100644 examples/practice-b-proconio.rs create mode 100644 examples/practice-b-text-io.rs create mode 100644 examples/practice-b-whiteread.rs diff --git a/examples/practice-b-naive.rs b/examples/practice-b-naive.rs new file mode 100644 index 0000000..2723533 --- /dev/null +++ b/examples/practice-b-naive.rs @@ -0,0 +1,108 @@ +// https://atcoder.jp/contests/practice/tasks/practice_2 + +use maplit::hashset; + +use std::io; + +fn main() { + fn read_line() -> String { + let mut input = "".to_owned(); + io::stdin().read_line(&mut input).unwrap(); + input + } + + fn query(l: u8, r: u8) -> bool { + println!("? {} {}", l as char, r as char); + read_line() == "<\n" + } + + let n = { + let input = read_line(); + let mut input = input.split_whitespace(); + macro_rules! read(($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap())); + read!(u32) + }; + + let ans = match n { + 26 => on_26(query), + 5 => on_5(query), + _ => unreachable!(), + }; + println!("! {}", String::from_utf8(ans).unwrap()); +} + +fn on_26(mut query: impl FnMut(u8, u8) -> bool) -> Vec { + (b'B'..=b'Z').fold(vec![b'A'], |balls, ball| insort(balls, ball, &mut query)) +} + +#[allow(clippy::many_single_char_names)] +fn on_5(mut query: impl FnMut(u8, u8) -> bool) -> Vec { + let (r, s, t, u) = { + let (q1, q2) = (query(b'A', b'B'), query(b'C', b'D')); + let (light1, heavy1) = if q1 { (b'A', b'B') } else { (b'B', b'A') }; + let (light2, heavy2) = if q2 { (b'C', b'D') } else { (b'D', b'C') }; + let q3 = query(light1, light2); + if q3 { + (light1, heavy1, light2, heavy2) + } else { + (light2, heavy2, light1, heavy1) + } + }; + + let v = (&hashset!(b'A', b'B', b'C', b'D', b'E') - &hashset!(r, s, t, u)) + .into_iter() + .next() + .unwrap(); + + let q4 = query(t, v); + if q4 { + let q5 = query(u, v); + let (min_uv, max_uv) = if q5 { (u, v) } else { (v, u) }; + itertools::chain(vec![r], insort(vec![t, min_uv, max_uv], s, &mut query)).collect() + } else { + let q5 = query(r, v); + if q5 { + itertools::chain(vec![r], insort(vec![v, t, u], s, &mut query)).collect() + } else { + itertools::chain(vec![v, r], insort(vec![t, u], s, &mut query)).collect() + } + } +} + +fn insort(mut balls: Vec, ball: u8, mut query: impl FnMut(u8, u8) -> bool) -> Vec { + let (mut min, mut max) = (0, balls.len()); + while min < max { + let mid = (min + max) / 2; + if query(balls[mid], ball) { + min = mid + 1; + } else { + max = mid + }; + } + balls.insert(min, ball); + balls +} + +#[cfg(test)] +mod tests { + use itertools::Itertools as _; + + use std::str; + + #[test] + fn on_5() { + for balls in (b'A'..=b'E').permutations(5) { + let mut queries = 0; + let ans = super::on_5(|l, r| { + queries += 1; + let wl = balls.iter().position(|&b| b == l).unwrap(); + let wr = balls.iter().position(|&b| b == r).unwrap(); + wl < wr + }); + let ans = str::from_utf8(&ans).unwrap(); + let balls = str::from_utf8(&balls).unwrap(); + assert_eq!(ans, balls); + assert!(queries <= 7); + } + } +} diff --git a/examples/practice-b-proconio.rs b/examples/practice-b-proconio.rs new file mode 100644 index 0000000..2735590 --- /dev/null +++ b/examples/practice-b-proconio.rs @@ -0,0 +1,107 @@ +// https://atcoder.jp/contests/practice/tasks/practice_2 + +use maplit::hashset; +use proconio::input; +use proconio::source::line::LineSource; + +use std::io; + +fn main() { + let stdin = io::stdin(); + let mut stdin = stdin.lock(); + + input! { + from LineSource::new(&mut stdin), + n: u32, + } + + let query = |l: u8, r: u8| -> _ { + println!("? {} {}", l as char, r as char); + input! { + from LineSource::new(&mut stdin), + c: char, + } + c == '<' + }; + + let ans = match n { + 26 => on_26(query), + 5 => on_5(query), + _ => unreachable!(), + }; + println!("! {}", String::from_utf8(ans).unwrap()); +} + +fn on_26(mut query: impl FnMut(u8, u8) -> bool) -> Vec { + (b'B'..=b'Z').fold(vec![b'A'], |balls, ball| insort(balls, ball, &mut query)) +} + +#[allow(clippy::many_single_char_names)] +fn on_5(mut query: impl FnMut(u8, u8) -> bool) -> Vec { + let (r, s, t, u) = { + let (q1, q2) = (query(b'A', b'B'), query(b'C', b'D')); + let (light1, heavy1) = if q1 { (b'A', b'B') } else { (b'B', b'A') }; + let (light2, heavy2) = if q2 { (b'C', b'D') } else { (b'D', b'C') }; + let q3 = query(light1, light2); + if q3 { + (light1, heavy1, light2, heavy2) + } else { + (light2, heavy2, light1, heavy1) + } + }; + + let v = (&hashset!(b'A', b'B', b'C', b'D', b'E') - &hashset!(r, s, t, u)) + .into_iter() + .next() + .unwrap(); + + let q4 = query(t, v); + if q4 { + let q5 = query(u, v); + let (min_uv, max_uv) = if q5 { (u, v) } else { (v, u) }; + itertools::chain(vec![r], insort(vec![t, min_uv, max_uv], s, &mut query)).collect() + } else { + let q5 = query(r, v); + if q5 { + itertools::chain(vec![r], insort(vec![v, t, u], s, &mut query)).collect() + } else { + itertools::chain(vec![v, r], insort(vec![t, u], s, &mut query)).collect() + } + } +} + +fn insort(mut balls: Vec, ball: u8, mut query: impl FnMut(u8, u8) -> bool) -> Vec { + let (mut min, mut max) = (0, balls.len()); + while min < max { + let mid = (min + max) / 2; + if query(balls[mid], ball) { + min = mid + 1; + } else { + max = mid + }; + } + balls.insert(min, ball); + balls +} + +#[cfg(test)] +mod tests { + use itertools::Itertools as _; + + use std::str; + + #[test] + fn on_5() { + for balls in (b'A'..=b'E').permutations(5) { + let mut queries = 0; + let ans = super::on_5(|l, r| { + queries += 1; + let wl = balls.iter().position(|&b| b == l).unwrap(); + let wr = balls.iter().position(|&b| b == r).unwrap(); + wl < wr + }); + assert_eq!(ans, balls); + assert!(queries <= 7); + } + } +} diff --git a/examples/practice-b-text-io.rs b/examples/practice-b-text-io.rs new file mode 100644 index 0000000..2774aa8 --- /dev/null +++ b/examples/practice-b-text-io.rs @@ -0,0 +1,106 @@ +// https://atcoder.jp/contests/practice/tasks/practice_2 + +use maplit::hashset; +use text_io::{read, try_read, try_scan}; + +use std::io; + +#[allow(clippy::try_err)] +fn main() { + fn read_line() -> String { + let mut input = "".to_owned(); + io::stdin().read_line(&mut input).unwrap(); + input + } + + let n: u32 = { + let line = read_line(); + read!("{}", line.bytes()) + }; + + let query = |l: u8, r: u8| -> _ { + println!("? {} {}", l as char, r as char); + read_line() == "<\n" + }; + + let ans = match n { + 26 => on_26(query), + 5 => on_5(query), + _ => unreachable!(), + }; + println!("! {}", String::from_utf8(ans).unwrap()); +} + +fn on_26(mut query: impl FnMut(u8, u8) -> bool) -> Vec { + (b'B'..=b'Z').fold(vec![b'A'], |balls, ball| insort(balls, ball, &mut query)) +} + +#[allow(clippy::many_single_char_names)] +fn on_5(mut query: impl FnMut(u8, u8) -> bool) -> Vec { + let (r, s, t, u) = { + let (q1, q2) = (query(b'A', b'B'), query(b'C', b'D')); + let (light1, heavy1) = if q1 { (b'A', b'B') } else { (b'B', b'A') }; + let (light2, heavy2) = if q2 { (b'C', b'D') } else { (b'D', b'C') }; + let q3 = query(light1, light2); + if q3 { + (light1, heavy1, light2, heavy2) + } else { + (light2, heavy2, light1, heavy1) + } + }; + + let v = (&hashset!(b'A', b'B', b'C', b'D', b'E') - &hashset!(r, s, t, u)) + .into_iter() + .next() + .unwrap(); + + let q4 = query(t, v); + if q4 { + let q5 = query(u, v); + let (min_uv, max_uv) = if q5 { (u, v) } else { (v, u) }; + itertools::chain(vec![r], insort(vec![t, min_uv, max_uv], s, &mut query)).collect() + } else { + let q5 = query(r, v); + if q5 { + itertools::chain(vec![r], insort(vec![v, t, u], s, &mut query)).collect() + } else { + itertools::chain(vec![v, r], insort(vec![t, u], s, &mut query)).collect() + } + } +} + +fn insort(mut balls: Vec, ball: u8, mut query: impl FnMut(u8, u8) -> bool) -> Vec { + let (mut min, mut max) = (0, balls.len()); + while min < max { + let mid = (min + max) / 2; + if query(balls[mid], ball) { + min = mid + 1; + } else { + max = mid + }; + } + balls.insert(min, ball); + balls +} + +#[cfg(test)] +mod tests { + use itertools::Itertools as _; + + use std::str; + + #[test] + fn on_5() { + for balls in (b'A'..=b'E').permutations(5) { + let mut queries = 0; + let ans = super::on_5(|l, r| { + queries += 1; + let wl = balls.iter().position(|&b| b == l).unwrap(); + let wr = balls.iter().position(|&b| b == r).unwrap(); + wl < wr + }); + assert_eq!(ans, balls); + assert!(queries <= 7); + } + } +} diff --git a/examples/practice-b-whiteread.rs b/examples/practice-b-whiteread.rs new file mode 100644 index 0000000..aacfd6f --- /dev/null +++ b/examples/practice-b-whiteread.rs @@ -0,0 +1,96 @@ +// https://atcoder.jp/contests/practice/tasks/practice_2 + +use maplit::hashset; +use whiteread::Reader; + +fn main() { + let mut rdr = Reader::from_stdin_naive(); + + let (n, _) = rdr.line::<(u32, u32)>().unwrap(); + + let query = |l: u8, r: u8| -> _ { + println!("? {} {}", l as char, r as char); + rdr.p::() == '<' + }; + + let ans = match n { + 26 => on_26(query), + 5 => on_5(query), + _ => unreachable!(), + }; + println!("! {}", String::from_utf8(ans).unwrap()); +} + +fn on_26(mut query: impl FnMut(u8, u8) -> bool) -> Vec { + (b'B'..=b'Z').fold(vec![b'A'], |balls, ball| insort(balls, ball, &mut query)) +} + +#[allow(clippy::many_single_char_names)] +fn on_5(mut query: impl FnMut(u8, u8) -> bool) -> Vec { + let (r, s, t, u) = { + let (q1, q2) = (query(b'A', b'B'), query(b'C', b'D')); + let (light1, heavy1) = if q1 { (b'A', b'B') } else { (b'B', b'A') }; + let (light2, heavy2) = if q2 { (b'C', b'D') } else { (b'D', b'C') }; + let q3 = query(light1, light2); + if q3 { + (light1, heavy1, light2, heavy2) + } else { + (light2, heavy2, light1, heavy1) + } + }; + + let v = (&hashset!(b'A', b'B', b'C', b'D', b'E') - &hashset!(r, s, t, u)) + .into_iter() + .next() + .unwrap(); + + let q4 = query(t, v); + if q4 { + let q5 = query(u, v); + let (min_uv, max_uv) = if q5 { (u, v) } else { (v, u) }; + itertools::chain(vec![r], insort(vec![t, min_uv, max_uv], s, &mut query)).collect() + } else { + let q5 = query(r, v); + if q5 { + itertools::chain(vec![r], insort(vec![v, t, u], s, &mut query)).collect() + } else { + itertools::chain(vec![v, r], insort(vec![t, u], s, &mut query)).collect() + } + } +} + +fn insort(mut balls: Vec, ball: u8, mut query: impl FnMut(u8, u8) -> bool) -> Vec { + let (mut min, mut max) = (0, balls.len()); + while min < max { + let mid = (min + max) / 2; + if query(balls[mid], ball) { + min = mid + 1; + } else { + max = mid + }; + } + balls.insert(min, ball); + balls +} + +#[cfg(test)] +mod tests { + use itertools::Itertools as _; + + use std::str; + + #[test] + fn on_5() { + for balls in (b'A'..=b'E').permutations(5) { + let mut queries = 0; + let ans = super::on_5(|l, r| { + queries += 1; + let wl = balls.iter().position(|&b| b == l).unwrap(); + let wr = balls.iter().position(|&b| b == r).unwrap(); + wl < wr + }); + assert_eq!(ans, balls); + assert!(queries <= 7); + } + } +} diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml index 4b7cab1..4c0085c 100644 --- a/test-with-generated-opts.toml +++ b/test-with-generated-opts.toml @@ -212,6 +212,26 @@ matching = "Exact" alt_testcases = [{ in = "1\n2 3\ntest", out = "6 test\n" }, { in = "72\n128 256\nmyonmyon", out = "456 myonmyon\n" }] meta = { using = ["whiteread"] } +# [examples.practice-b-naive] +# name = "practice contest: B - Interactive Sorting" +# url = "https://atcoder.jp/contests/practice/tasks/practice_2" +# meta = { using = ["itertools"] } +# +# [examples.practice-b-proconio] +# name = "practice contest: B - Interactive Sorting" +# url = "https://atcoder.jp/contests/practice/tasks/practice_2" +# meta = { using = ["itertools", "proconio"] } +# +# [examples.practice-b-text-io] +# name = "practice contest: B - Interactive Sorting" +# url = "https://atcoder.jp/contests/practice/tasks/practice_2" +# meta = { using = ["itertools", "text-io"] } +# +# [examples.practice-b-whiteread] +# name = "practice contest: B - Interactive Sorting" +# url = "https://atcoder.jp/contests/practice/tasks/practice_2" +# meta = { using = ["itertools", "whiteread"] } + [examples.sumitrust2019-c] name = "Sumitomo Mitsui Trust Bank Programming Contest 2019: C - 100 to 105" url = "https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_c" From f157fc711ad457aeacffe68859c003d2e6bb609c Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Fri, 17 Jan 2020 01:41:31 +0900 Subject: [PATCH 35/39] Test `practice-b-*` --- .github/workflows/ci.yml | 5 + examples/practice-b-naive.rs | 4 +- examples/practice-b-proconio.rs | 6 +- examples/practice-b-text-io.rs | 6 +- examples/practice-b-whiteread.rs | 6 +- examples/testers/practice-b.py | 58 ++++++ test-with-generated-opts.toml | 85 ++++++--- tools/test-with-generated-opts/Cargo.toml | 19 +- tools/test-with-generated-opts/src/main.rs | 207 +++++++++++++++------ 9 files changed, 305 insertions(+), 91 deletions(-) create mode 100644 examples/testers/practice-b.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a5878a..077dcd0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,6 +57,11 @@ jobs: - name: Checkout uses: actions/checkout@v1 + - name: setup-python + uses: actions/setup-python@v1 + with: + python-version: '3.8' + - name: rust-toolchain uses: actions-rs/toolchain@v1 with: diff --git a/examples/practice-b-naive.rs b/examples/practice-b-naive.rs index 2723533..e937181 100644 --- a/examples/practice-b-naive.rs +++ b/examples/practice-b-naive.rs @@ -2,7 +2,7 @@ use maplit::hashset; -use std::io; +use std::{io, str}; fn main() { fn read_line() -> String { @@ -28,7 +28,7 @@ fn main() { 5 => on_5(query), _ => unreachable!(), }; - println!("! {}", String::from_utf8(ans).unwrap()); + println!("! {}", str::from_utf8(&ans).unwrap()); } fn on_26(mut query: impl FnMut(u8, u8) -> bool) -> Vec { diff --git a/examples/practice-b-proconio.rs b/examples/practice-b-proconio.rs index 2735590..47f2d9b 100644 --- a/examples/practice-b-proconio.rs +++ b/examples/practice-b-proconio.rs @@ -4,7 +4,7 @@ use maplit::hashset; use proconio::input; use proconio::source::line::LineSource; -use std::io; +use std::{io, str}; fn main() { let stdin = io::stdin(); @@ -29,7 +29,7 @@ fn main() { 5 => on_5(query), _ => unreachable!(), }; - println!("! {}", String::from_utf8(ans).unwrap()); + println!("! {}", str::from_utf8(&ans).unwrap()); } fn on_26(mut query: impl FnMut(u8, u8) -> bool) -> Vec { @@ -100,6 +100,8 @@ mod tests { let wr = balls.iter().position(|&b| b == r).unwrap(); wl < wr }); + let ans = str::from_utf8(&ans).unwrap(); + let balls = str::from_utf8(&balls).unwrap(); assert_eq!(ans, balls); assert!(queries <= 7); } diff --git a/examples/practice-b-text-io.rs b/examples/practice-b-text-io.rs index 2774aa8..df3960e 100644 --- a/examples/practice-b-text-io.rs +++ b/examples/practice-b-text-io.rs @@ -3,7 +3,7 @@ use maplit::hashset; use text_io::{read, try_read, try_scan}; -use std::io; +use std::{io, str}; #[allow(clippy::try_err)] fn main() { @@ -28,7 +28,7 @@ fn main() { 5 => on_5(query), _ => unreachable!(), }; - println!("! {}", String::from_utf8(ans).unwrap()); + println!("! {}", str::from_utf8(&ans).unwrap()); } fn on_26(mut query: impl FnMut(u8, u8) -> bool) -> Vec { @@ -99,6 +99,8 @@ mod tests { let wr = balls.iter().position(|&b| b == r).unwrap(); wl < wr }); + let ans = str::from_utf8(&ans).unwrap(); + let balls = str::from_utf8(&balls).unwrap(); assert_eq!(ans, balls); assert!(queries <= 7); } diff --git a/examples/practice-b-whiteread.rs b/examples/practice-b-whiteread.rs index aacfd6f..0f93295 100644 --- a/examples/practice-b-whiteread.rs +++ b/examples/practice-b-whiteread.rs @@ -3,6 +3,8 @@ use maplit::hashset; use whiteread::Reader; +use std::str; + fn main() { let mut rdr = Reader::from_stdin_naive(); @@ -18,7 +20,7 @@ fn main() { 5 => on_5(query), _ => unreachable!(), }; - println!("! {}", String::from_utf8(ans).unwrap()); + println!("! {}", str::from_utf8(&ans).unwrap()); } fn on_26(mut query: impl FnMut(u8, u8) -> bool) -> Vec { @@ -89,6 +91,8 @@ mod tests { let wr = balls.iter().position(|&b| b == r).unwrap(); wl < wr }); + let ans = str::from_utf8(&ans).unwrap(); + let balls = str::from_utf8(&balls).unwrap(); assert_eq!(ans, balls); assert!(queries <= 7); } diff --git a/examples/testers/practice-b.py b/examples/testers/practice-b.py new file mode 100644 index 0000000..00a5ffb --- /dev/null +++ b/examples/testers/practice-b.py @@ -0,0 +1,58 @@ +import itertools +import random +import string +from argparse import ArgumentParser +from subprocess import Popen, PIPE +from typing import List + + +def main() -> None: + parser = ArgumentParser() + parser.add_argument('bin') + + binary = parser.parse_args().bin + + for _ in range(100): + judge(binary, ''.join(random.sample(string.ascii_uppercase, 26))) + + for balls in itertools.permutations(string.ascii_uppercase[:5]): + judge(binary, ''.join(balls)) + + +def judge(binary: str, balls: str) -> None: + n = len(balls) + q = 7 if n == 5 else 100 + + with Popen([binary], stdin=PIPE, stdout=PIPE) as proc: + def read_words() -> List[str]: + return proc.stdout.readline().decode('utf-8').split() + + def on_query(c1: str, c2: str) -> None: + reply = '<' if balls.index(c1) < balls.index(c2) else '>' + proc.stdin.write(f'{reply}\n'.encode('utf-8')) + proc.stdin.flush() + + def on_answer(ans: str) -> None: + if ans != balls: + raise Exception('wrong answer') + + proc.stdin.write(f'{n} {q}\n'.encode('utf-8')) + proc.stdin.flush() + + for _ in range(q): + words = read_words() + if len(words) == 3 and words[0] == '?': + on_query(words[1], words[2]) + elif len(words) == 2 and words[0] == '!': + return on_answer(words[1]) + else: + raise Exception('invalid') + else: + words = read_words() + if len(words) == 2 and words[0] == '!': + return on_answer(words[1]) + raise Exception('answer me') + + +if __name__ == '__main__': + main() diff --git a/test-with-generated-opts.toml b/test-with-generated-opts.toml index 4c0085c..7d0d572 100644 --- a/test-with-generated-opts.toml +++ b/test-with-generated-opts.toml @@ -1,147 +1,171 @@ # Dropboxからのダウンロードは行なわない。(面倒なのと誰のアカウントを使うかという問題がある) -bin = "./target/test-with-generated-opts/bin/{}" -testcases = "./target/test-with-generated-opts/testcases/{}" +bin = "./target/test-with-generated-opts/bin/{problem}" +testcases = "./target/test-with-generated-opts/testcases/{problem}" [examples.abc054-c] +type = "Normal" name = "ABC054: C - One-stroke Path" url = "https://atcoder.jp/contests/abc054/tasks/abc054_c" matching = "Words" meta = { using = ["itertools", "petgraph"] } [examples.abc057-b-naive] +type = "Normal" name = "ABC057: B - Checkpoints" url = "https://atcoder.jp/contests/abc057/tasks/abc057_b" matching = "Words" meta = { using = [] } # 下3つと比較するため [examples.abc057-b-proconio] +type = "Normal" name = "ABC057: B - Checkpoints" url = "https://atcoder.jp/contests/abc057/tasks/abc057_b" matching = "Words" meta = { using = ["proconio"] } [examples.abc057-b-text-io] +type = "Normal" name = "ABC057: B - Checkpoints" url = "https://atcoder.jp/contests/abc057/tasks/abc057_b" matching = "Words" meta = { using = ["text_io"] } [examples.abc057-b-whiteread] +type = "Normal" name = "ABC057: B - Checkpoints" url = "https://atcoder.jp/contests/abc057/tasks/abc057_b" matching = "Words" meta = { using = ["whiteread"] } [examples.abc073-d] +type = "Normal" name = "ABC073: D - joisino's travel" url = "https://atcoder.jp/contests/abc073/tasks/abc073_d" matching = "Words" meta = { using = ["itertools", "petgraph"] } [examples.abc084-d] +type = "Normal" name = "ABC084: D - 2017-like Number" url = "https://atcoder.jp/contests/abc084/tasks/abc084_d" matching = "Words" meta = { using = ["itertools-num", "primal"] } [examples.abc118-b-naive] +type = "Normal" name = "ABC118: B - Foods Loved by Everyone" url = "https://atcoder.jp/contests/abc118/tasks/abc118_b" matching = "Words" meta = { using = [] } # 下3つと比較するため [examples.abc118-b-proconio] +type = "Normal" name = "ABC118: B - Foods Loved by Everyone" url = "https://atcoder.jp/contests/abc118/tasks/abc118_b" matching = "Words" meta = { using = ["proconio"] } [examples.abc118-b-text-io] +type = "Normal" name = "ABC118: B - Foods Loved by Everyone" url = "https://atcoder.jp/contests/abc118/tasks/abc118_b" matching = "Words" meta = { using = ["text-io"] } [examples.abc118-b-whiteread] +type = "Normal" name = "ABC118: B - Foods Loved by Everyone" url = "https://atcoder.jp/contests/abc118/tasks/abc118_b" matching = "Words" meta = { using = ["whiteread"] } [examples.abc120-d] +type = "Normal" name = "ABC120: D - Decayed Bridges" url = "https://atcoder.jp/contests/abc120/tasks/abc120_d" matching = "Words" meta = { using = ["union-find"] } [examples.abc121-b-naive] +type = "Normal" name = "ABC121: B - Can you solve this?" url = "https://atcoder.jp/contests/abc121/tasks/abc121_b" matching = "Words" meta = { using = [] } # 下3つと比較するため [examples.abc121-b-proconio] +type = "Normal" name = "ABC121: B - Can you solve this?" url = "https://atcoder.jp/contests/abc121/tasks/abc121_b" matching = "Words" meta = { using = ["proconio"] } [examples.abc121-b-text-io] +type = "Normal" name = "ABC121: B - Can you solve this?" url = "https://atcoder.jp/contests/abc121/tasks/abc121_b" matching = "Words" meta = { using = ["text_io"] } [examples.abc121-b-whiteread] +type = "Normal" name = "ABC121: B - Can you solve this?" url = "https://atcoder.jp/contests/abc121/tasks/abc121_b" matching = "Words" meta = { using = ["whiteread"] } [examples.abc129-f] +type = "Normal" name = "ABC129: F - Takahashi's Basics in Education and Learning" url = "https://atcoder.jp/contests/abc129/tasks/abc129_f" matching = "Words" meta = { using = ["derive_more", "ndarray", "num", "num-derive"] } [examples.abc141-c] +type = "Normal" name = "ABC141: C - Attack Survival" url = "https://atcoder.jp/contests/abc141/tasks/abc141_c" matching = "Words" meta = { using = ["proconio"] } [examples.abc142-c] +type = "Normal" name = "ABC142: C - Go to School" url = "https://atcoder.jp/contests/abc142/tasks/abc142_c" matching = "Words" meta = { using = ["itertools", "superslice"] } [examples.abc142-d] +type = "Normal" name = "ABC142: D - Disjoint Set of Common Divisors" url = "https://atcoder.jp/contests/abc142/tasks/abc142_d" matching = "Words" meta = { using = ["num-integer", "primal"] } [examples.abc144-d] +type = "Normal" name = "ABC144: D - Water Bottle" url = "https://atcoder.jp/contests/abc144/tasks/abc144_d" matching = { FloatOr = { abs = 1e-6, rel = 1e-6 } } meta = { using = ["libm"] } [examples.abc150-d] +type = "Normal" name = "ABC150: D - Semi Common Multiple" url = "https://atcoder.jp/contests/abc150/tasks/abc150_d" matching = "Words" meta = { using = ["itertools", "num"] } [examples.abc151-d] +type = "Normal" name = "ABC151: D - Maze Master" url = "https://atcoder.jp/contests/abc151/tasks/abc151_d" matching = "Words" meta = { using = ["itertools", "ndarray", "smallvec"] } [examples.apg4b-a] +type = "Normal" name = "APG4b: A - 1.00.はじめに" url = "https://atcoder.jp/contests/APG4b/tasks/APG4b_a" matching = "Exact" @@ -149,42 +173,49 @@ alt_testcases = [{ in = "", out = "Hello, world!\n" }] meta = { using = ["aho-corasick", "alga", "approx", "ascii", "bitset-fixed", "defmac", "derive_more", "derive-new", "either", "euclid", "fixedbitset", "getrandom", "jemallocator", "jemalloc-ctl", "if_chain", "im-rc", "indexmap", "itertools", "itertools-num", "lazy_static", "libm", "maplit", "matches", "modtype", "nalgebra", "ndarray", "nom", "num", "num-bigint", "num-complex", "num-derive", "num-integer", "num-iter", "num-rational", "num-traits", "ordered-float", "permutohedron", "petgraph", "primal", "primal-check", "primal-estimate", "primal-sieve", "proconio", "rand", "rand_chacha", "rand_core", "rand_distr", "rand_hc", "rand_pcg", "regex", "rustc-hash", "smallvec", "strsim", "superslice", "take_mut", "text_io", "union-find", "whiteread"] } [examples.apg4b-ex25] +type = "Normal" name = "APG4b: EX25 - 集合の操作 / 3.05" url = "https://atcoder.jp/contests/APG4b/tasks/APG4b_bx" matching = "Words" meta = { using = ["fixedbitset", "itertools"] } [examples.apg4b-ex26] +type = "Normal" name = "APG4b: EX26 - 電卓を作ろう3 / 3.06" url = "https://atcoder.jp/contests/APG4b/tasks/APG4b_bw" matching = "Exact" meta = { using = ["itertools", "maplit", "matches", "nom"] } [examples.arc065-c] +type = "Normal" name = "ABC049 / ARC065: C - 白昼夢 / Daydream" url = "https://atcoder.jp/contests/arc065/tasks/arc065_a" matching = "Words" meta = { using = ["lazy_static", "regex"] } [examples.arc084-c] +type = "Normal" name = "ABC077 / ARC084: C - Snuke Festival" url = "https://atcoder.jp/contests/arc084/tasks/arc084_a" matching = "Words" meta = { using = ["superslice"] } [examples.atc001-b] +type = "Normal" name = "ATC001: B - Union Find" url = "https://atcoder.jp/contests/atc001/tasks/unionfind_a" matching = "Words" meta = { using = ["petgraph"] } [examples.atc002-b] +type = "Normal" name = "ATC002: B - n^p mod m" url = "https://atcoder.jp/contests/atc002/tasks/atc002_b" matching = "Words" meta = { using = ["num"] } [examples.practice-a-naive] +type = "Normal" name = "practice contest: A - Welcome to AtCoder" url = "https://atcoder.jp/contests/practice/tasks/practice_1" matching = "Exact" @@ -192,6 +223,7 @@ alt_testcases = [{ in = "1\n2 3\ntest", out = "6 test\n" }, { in = "72\n128 256\ meta = { using = [] } # 下3つと比較するため [examples.practice-a-proconio] +type = "Normal" name = "practice contest: A - Welcome to AtCoder" url = "https://atcoder.jp/contests/practice/tasks/practice_1" matching = "Exact" @@ -199,6 +231,7 @@ alt_testcases = [{ in = "1\n2 3\ntest", out = "6 test\n" }, { in = "72\n128 256\ meta = { using = ["proconio"] } [examples.practice-a-text-io] +type = "Normal" name = "practice contest: A - Welcome to AtCoder" url = "https://atcoder.jp/contests/practice/tasks/practice_1" matching = "Exact" @@ -206,33 +239,43 @@ alt_testcases = [{ in = "1\n2 3\ntest", out = "6 test\n" }, { in = "72\n128 256\ meta = { using = ["text-io"] } [examples.practice-a-whiteread] +type = "Normal" name = "practice contest: A - Welcome to AtCoder" url = "https://atcoder.jp/contests/practice/tasks/practice_1" matching = "Exact" alt_testcases = [{ in = "1\n2 3\ntest", out = "6 test\n" }, { in = "72\n128 256\nmyonmyon", out = "456 myonmyon\n" }] meta = { using = ["whiteread"] } -# [examples.practice-b-naive] -# name = "practice contest: B - Interactive Sorting" -# url = "https://atcoder.jp/contests/practice/tasks/practice_2" -# meta = { using = ["itertools"] } -# -# [examples.practice-b-proconio] -# name = "practice contest: B - Interactive Sorting" -# url = "https://atcoder.jp/contests/practice/tasks/practice_2" -# meta = { using = ["itertools", "proconio"] } -# -# [examples.practice-b-text-io] -# name = "practice contest: B - Interactive Sorting" -# url = "https://atcoder.jp/contests/practice/tasks/practice_2" -# meta = { using = ["itertools", "text-io"] } -# -# [examples.practice-b-whiteread] -# name = "practice contest: B - Interactive Sorting" -# url = "https://atcoder.jp/contests/practice/tasks/practice_2" -# meta = { using = ["itertools", "whiteread"] } +[examples.practice-b-naive] +type = "Special" +name = "practice contest: B - Interactive Sorting" +url = "https://atcoder.jp/contests/practice/tasks/practice_2" +tester = ["python", "./examples/testers/practice-b.py", "{bin}"] +meta = { using = ["itertools", "maplit"] } + +[examples.practice-b-proconio] +type = "Special" +name = "practice contest: B - Interactive Sorting" +url = "https://atcoder.jp/contests/practice/tasks/practice_2" +tester = ["python", "./examples/testers/practice-b.py", "{bin}"] +meta = { using = ["itertools", "maplit", "proconio"] } + +[examples.practice-b-text-io] +type = "Special" +name = "practice contest: B - Interactive Sorting" +url = "https://atcoder.jp/contests/practice/tasks/practice_2" +tester = ["python", "./examples/testers/practice-b.py", "{bin}"] +meta = { using = ["itertools", "maplit", "text-io"] } + +[examples.practice-b-whiteread] +type = "Special" +name = "practice contest: B - Interactive Sorting" +url = "https://atcoder.jp/contests/practice/tasks/practice_2" +tester = ["python", "./examples/testers/practice-b.py", "{bin}"] +meta = { using = ["itertools", "maplit", "whiteread"] } [examples.sumitrust2019-c] +type = "Normal" name = "Sumitomo Mitsui Trust Bank Programming Contest 2019: C - 100 to 105" url = "https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_c" matching = "Words" diff --git a/tools/test-with-generated-opts/Cargo.toml b/tools/test-with-generated-opts/Cargo.toml index 3841904..525fc90 100644 --- a/tools/test-with-generated-opts/Cargo.toml +++ b/tools/test-with-generated-opts/Cargo.toml @@ -6,21 +6,24 @@ publish = false description = "Test with `rustc-dep-option-generator`." [dependencies] -anyhow = "1.0.25" +anyhow = "1.0.26" approx = "0.3.2" env_logger = "0.7.1" -indexmap = { version = "1.3.0", features = ["serde-1"] } +indexmap = { version = "1.3.1", features = ["serde-1"] } itertools = "0.8.2" log = "0.4.8" -nom = "5.0.1" -once_cell = "1.2.0" -regex = "1.3.1" +maplit = "1.0.2" +nom = "5.1.0" +once_cell = "1.3.0" +regex = "1.3.3" scraper = "0.11.0" serde = { version = "1.0.104", features = ["derive"] } serde_json = "1.0.44" shell-escape = "0.1.4" -structopt = "0.3.5" +structopt = "0.3.7" toml = "0.5.5" -ureq = "0.11.2" -url = { version = "2.1.0", features = ["serde"] } +ureq = "0.11.3" +url = { version = "2.1.1", features = ["serde"] } which = { version = "3.1.0", default-features = false } +either = "1.5.3" +fallible-iterator = "0.2.0" diff --git a/tools/test-with-generated-opts/src/main.rs b/tools/test-with-generated-opts/src/main.rs index 493000f..310aa92 100644 --- a/tools/test-with-generated-opts/src/main.rs +++ b/tools/test-with-generated-opts/src/main.rs @@ -1,9 +1,12 @@ use anyhow::{anyhow, ensure, Context as _}; use approx::{abs_diff_eq, relative_eq}; +use either::Either; use env_logger::fmt::Color; +use fallible_iterator::FallibleIterator as _; use indexmap::IndexMap; use itertools::Itertools as _; use log::{info, Level, LevelFilter}; +use maplit::hashmap; use once_cell::sync::Lazy; use regex::Regex; use scraper::{Html, Selector}; @@ -12,9 +15,10 @@ use serde::{Deserialize, Deserializer}; use structopt::StructOpt; use url::Url; -use std::collections::BTreeMap; +use std::collections::{BTreeMap, BTreeSet, HashMap}; use std::ffi::{OsStr, OsString}; use std::io::{self, Read as _, Write as _}; +use std::ops::Deref; use std::path::{Path, PathBuf}; use std::process::{Command, Output, Stdio}; use std::str::FromStr; @@ -66,44 +70,60 @@ fn main() -> anyhow::Result<()> { let tests = config .examples .iter() - .map( - |( - slug, - Example { - name, - url, + .map(|(slug, example)| { + let src = Path::new("./examples").join(slug).with_extension("rs"); + let bin = config.bin.expand_path(slug)?; + compile(&src, &bin)?; + + match example { + Example::Normal(Normal { + base: Base { name, url }, matching, alt_testcases, - }, - )| { - let testcases = if let Some(alt_testcases) = alt_testcases { - alt_testcases + }) => { + let testcases = if let Some(alt_testcases) = alt_testcases { + alt_testcases + .iter() + .enumerate() + .map(|(i, c)| { + ((i + 1).to_string().into(), (c.r#in.clone(), c.out.clone())) + }) + .collect() + } else { + load_testcases(&config.testcases.expand_path(slug)?)? + }; + Ok(Either::Left((name, url, bin, *matching, testcases))) + } + Example::Special(Special { + base: Base { name, url }, + tester, + }) => { + let tester = tester .iter() - .enumerate() - .map(|(i, c)| ((i + 1).to_string().into(), (c.r#in.clone(), c.out.clone()))) - .collect() - } else { - load_testcases(&config.testcases.expand(slug))? - }; - let src = Path::new("./examples").join(slug).with_extension("rs"); - let bin = config.bin.expand(slug); - compile(&src, &bin)?; - Ok((name, url, *matching, testcases, bin)) - }, - ) + .map(|t| t.expand_as_arg(&bin)) + .collect::>>()?; + Ok(Either::Right((name, url, bin, tester))) + } + } + }) .collect::>>()?; - for (name, url, matching, testcases, bin) in tests { - test(&name, &url, matching, &testcases, &bin)?; + for test in tests { + match test { + Either::Left((name, url, bin, matching, testcases)) => { + normal_test(&name, &url, matching, &testcases, &bin)? + } + Either::Right((name, url, bin, tester)) => special_test(&name, &url, &tester, &bin)?, + } } Ok(()) } fn scrape_sample_cases(config: &Config) -> anyhow::Result<()> { for (slug, example) in &config.examples { - let dst_dir = config.testcases.expand(slug); - if !(dst_dir.exists() || example.alt_testcases.is_some()) { - let samples = get_html(&example.url)?.extract_samples()?; + let dst_dir = config.testcases.expand_path(slug)?; + if example.requires_sample_cases() && !dst_dir.exists() { + let samples = get_html(&example.url())?.extract_samples()?; save_testcases(&dst_dir, &samples)?; } } @@ -439,7 +459,7 @@ fn compile(src: &Path, bin: &Path) -> anyhow::Result<()> { run_command(program, args).map(drop) } -fn test( +fn normal_test( task_name: &str, url: &Url, matching: Matching, @@ -491,6 +511,29 @@ fn test( Ok(()) } +fn special_test(task_name: &str, url: &Url, tester: &[OsString], bin: &Path) -> anyhow::Result<()> { + info!("Testing {}", bin.display()); + info!(" Name: {:?}", task_name); + info!(" URL: {}", url); + info!(" Arguments: {:?}", tester); + + let start = Instant::now(); + let arg0 = tester.get(0).map(Deref::deref).unwrap_or_default(); + let status = Command::new(arg0) + .args(&tester[1..]) + .status() + .with_context(|| format!("Failed to execute {}", arg0.to_string_lossy()))?; + let stop = Instant::now(); + let time = (stop - start).as_millis(); + let verdict = if status.success() { "AC" } else { "WA" }; + + info!("{} in {}ms", verdict, time); + if verdict != "AC" { + return Err(anyhow!("Test failed")); + } + Ok(()) +} + fn read_to_string(path: impl AsRef) -> anyhow::Result { let path = path.as_ref(); fs::read_to_string(path).with_context(|| format!("Failed to read {}", path.display())) @@ -547,52 +590,70 @@ impl BoolExt for bool { #[derive(Debug, Deserialize)] struct Config { - bin: PathTemplate, - testcases: PathTemplate, + bin: Template, + testcases: Template, examples: IndexMap, } #[derive(Debug)] -struct PathTemplate(Vec); - -impl PathTemplate { - fn expand(&self, slug: &str) -> PathBuf { - self.0 - .iter() - .map(|token| match token { - PathTemplateToken::Brace => slug, - PathTemplateToken::Plain(plain) => plain, - }) - .join("") - .into() +struct Template(Vec); + +impl Template { + fn expand(&self, vars: &HashMap<&str, &OsStr>) -> anyhow::Result { + let args = self.0.iter().map(|token| match token { + TemplateToken::Brace(name) => vars.get(&**name).copied().ok_or_else(|| { + anyhow!( + "Undefined variable {:?} (expected {:?})", + name, + vars.keys().collect::>(), + ) + }), + TemplateToken::Plain(plain) => Ok(plain.as_ref()), + }); + fallible_iterator::convert(args).fold(OsString::new(), |mut acc, arg| { + acc.push(arg); + Ok(acc) + }) + } + + fn expand_path(&self, slug: &str) -> anyhow::Result { + let vars = hashmap!("problem" => slug.as_ref()); + self.expand(&vars).map(Into::into) + } + + fn expand_as_arg(&self, bin: &Path) -> anyhow::Result { + let vars = hashmap!("bin" => bin.as_ref()); + self.expand(&vars) } } -impl<'de> Deserialize<'de> for PathTemplate { +impl<'de> Deserialize<'de> for Template { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { use nom::branch::alt; use nom::bytes::complete::take_while1; - use nom::character::complete::{char, space0}; + use nom::character::complete::{alphanumeric1, char, space0}; use nom::multi::many0; use nom::IResult; - fn tokens(input: &str) -> IResult<&str, Vec> { + fn tokens(input: &str) -> IResult<&str, Vec> { many0(alt((brace, plain)))(input) } - fn brace(input: &str) -> IResult<&str, PathTemplateToken> { + fn brace(input: &str) -> IResult<&str, TemplateToken> { let (input, _) = char('{')(input)?; let (input, _) = space0(input)?; + let (input, name) = alphanumeric1(input)?; + let (input, _) = space0(input)?; let (input, _) = char('}')(input)?; - Ok((input, PathTemplateToken::Brace)) + Ok((input, TemplateToken::Brace(name.to_owned()))) } - fn plain(input: &str) -> IResult<&str, PathTemplateToken> { + fn plain(input: &str) -> IResult<&str, TemplateToken> { let (input, plain) = take_while1(|c| !['{', '}'].contains(&c))(input)?; - Ok((input, PathTemplateToken::Plain(plain.to_owned()))) + Ok((input, TemplateToken::Plain(plain.to_owned()))) } let input = String::deserialize(deserializer)?; @@ -607,19 +668,55 @@ impl<'de> Deserialize<'de> for PathTemplate { } #[derive(Debug)] -enum PathTemplateToken { - Brace, +enum TemplateToken { + Brace(String), Plain(String), } #[derive(Debug, Deserialize)] -struct Example { - name: String, - url: Url, +#[serde(tag = "type")] +enum Example { + Normal(Normal), + Special(Special), +} + +impl Example { + fn url(&self) -> &Url { + match self { + Self::Normal(this) => &this.base.url, + Self::Special(this) => &this.base.url, + } + } + + fn requires_sample_cases(&self) -> bool { + match self { + Self::Normal(this) => this.alt_testcases.is_none(), + Self::Special(_) => false, + } + } +} + +#[derive(Debug, Deserialize)] +struct Normal { + #[serde(flatten)] + base: Base, matching: Matching, alt_testcases: Option>, } +#[derive(Debug, Deserialize)] +struct Special { + #[serde(flatten)] + base: Base, + tester: Vec