diff --git a/examples/abc120-d.rs b/examples/abc120-d.rs index 27810d2..92e33ee 100644 --- a/examples/abc120-d.rs +++ b/examples/abc120-d.rs @@ -1,11 +1,38 @@ // https://atcoder.jp/contests/abc120/tasks/abc120_d -use proconio::marker::Usize1; -use proconio::{fastout, input}; use union_find::{QuickFindUf, UnionBySize, UnionFind as _}; -#[fastout] +#[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; + input! { n: usize, m: usize, diff --git a/examples/apg4b-a.rs b/examples/apg4b-a.rs index 20e8cfe..7eaf969 100644 --- a/examples/apg4b-a.rs +++ b/examples/apg4b-a.rs @@ -52,6 +52,7 @@ use strsim as _; use superslice as _; use take_mut as _; use text_io as _; +use union_find as _; use whiteread as _; #[cfg(feature = "jemalloc-ctl")] diff --git a/examples/arc065-c.rs b/examples/arc065-c.rs index fc8dfb2..46eb475 100644 --- a/examples/arc065-c.rs +++ b/examples/arc065-c.rs @@ -1,11 +1,38 @@ // https://atcoder.jp/contests/arc065/tasks/arc065_a use lazy_static::lazy_static; -use proconio::input; -use proconio::marker::Bytes; 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 proconio::input; + use proconio::marker::Bytes; + input! { s: Bytes, } diff --git a/examples/atc001-b.rs b/examples/atc001-b.rs new file mode 100644 index 0000000..f630b23 --- /dev/null +++ b/examples/atc001-b.rs @@ -0,0 +1,48 @@ +use petgraph::unionfind::UnionFind; + +#[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; + + input! { + n: usize, + q: usize, + pabs: [(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); + } + } +} diff --git a/examples/atc002-b.rs b/examples/atc002-b.rs new file mode 100644 index 0000000..f2a2a7b --- /dev/null +++ b/examples/atc002-b.rs @@ -0,0 +1,29 @@ +// https://atcoder.jp/contests/atc002/tasks/atc002_b + +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 proconio::input; + + input! { + n: BigUint, + m: BigUint, + p: BigUint, + } + + println!("{}", n.modpow(&p, &m)); +} diff --git a/examples/practice-a.rs b/examples/practice-a.rs index d7b635e..21a65b4 100644 --- a/examples/practice-a.rs +++ b/examples/practice-a.rs @@ -1,8 +1,20 @@ // https://atcoder.jp/contests/practice/tasks/practice_1 -use proconio::input; - +#[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 proconio::input; + input! { a: u32, b: u32, diff --git a/examples/tests.ron b/examples/tests.ron index 2b4f9ab..e86cc49 100644 --- a/examples/tests.ron +++ b/examples/tests.ron @@ -1,3 +1,6 @@ +// 手元でDropboxのテストケース(ある場合)で確認し、Gitに含めるのはそのうちサンプルのみ。 +// CI上でもサンプルだけテストする。(Dropboxから引っ張るのも面倒だし何より誰のアカウントを使うかという問題がある) + ( tests: { "apg4b-a": ( @@ -8,6 +11,14 @@ name: "practice contest: A - Welcome to AtCoder", matching: ExactWords, ), + "atc001-b": ( + name: "ATC001: B - Union Find", + matching: ExactWords, + ), + "atc002-b": ( + name: "ATC002: B - n^p mod m", + matching: ExactWords, + ), "arc065-c": ( name: "ABC049 / ARC065: C - 白昼夢 / Daydream", matching: ExactWords, diff --git a/examples/testsets/atc001-b/in/00_sample_01.txt b/examples/testsets/atc001-b/in/00_sample_01.txt new file mode 100644 index 0000000..632a776 --- /dev/null +++ b/examples/testsets/atc001-b/in/00_sample_01.txt @@ -0,0 +1,10 @@ +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 new file mode 100644 index 0000000..df9be86 --- /dev/null +++ b/examples/testsets/atc001-b/out/00_sample_01.txt @@ -0,0 +1,4 @@ +Yes +No +Yes +Yes diff --git a/examples/testsets/atc002-b/in/sample_01.txt b/examples/testsets/atc002-b/in/sample_01.txt new file mode 100644 index 0000000..2065346 --- /dev/null +++ b/examples/testsets/atc002-b/in/sample_01.txt @@ -0,0 +1 @@ +12 15 7 diff --git a/examples/testsets/atc002-b/in/sample_02.txt b/examples/testsets/atc002-b/in/sample_02.txt new file mode 100644 index 0000000..0903e42 --- /dev/null +++ b/examples/testsets/atc002-b/in/sample_02.txt @@ -0,0 +1 @@ +123456789 234567894 6574837563712 diff --git a/examples/testsets/atc002-b/out/sample_01.txt b/examples/testsets/atc002-b/out/sample_01.txt new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/examples/testsets/atc002-b/out/sample_01.txt @@ -0,0 +1 @@ +3 diff --git a/examples/testsets/atc002-b/out/sample_02.txt b/examples/testsets/atc002-b/out/sample_02.txt new file mode 100644 index 0000000..7ecdf4c --- /dev/null +++ b/examples/testsets/atc002-b/out/sample_02.txt @@ -0,0 +1 @@ +120678297