Skip to content

Commit 794585a

Browse files
committed
Add a test for ATC001-B
1 parent acb3091 commit 794585a

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed

examples/atc001-b.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
use petgraph::unionfind::UnionFind;
2+
3+
#[proconio::fastout]
4+
fn main() {
5+
// use std::io::{self, Read as _};
6+
//
7+
// let mut input = "".to_owned();
8+
// io::stdin().read_to_string(&mut input).unwrap();
9+
// let mut input = input.split_whitespace();
10+
// macro_rules! read {
11+
// ([$t:tt; $n:expr]) => {
12+
// (0..$n).map(|_| read!($t)).collect::<Vec<_>>()
13+
// };
14+
// (($($t:tt),+)) => {
15+
// ($(read!($t)),*)
16+
// };
17+
// (_1based) => {
18+
// read!(usize) - 1
19+
// };
20+
// (_bytes) => {
21+
// read!(String).into_bytes()
22+
// };
23+
// ($ty:ty) => {
24+
// input.next().unwrap().parse::<$ty>().unwrap()
25+
// };
26+
// }
27+
//
28+
// let (n, q) = read!((usize, usize));
29+
// let pabs = read!([(u8, usize, usize); q]);
30+
31+
use proconio::input;
32+
33+
input! {
34+
n: usize,
35+
q: usize,
36+
pabs: [(u8, usize, usize); q],
37+
}
38+
39+
let mut uf = UnionFind::new(n);
40+
for (p, a, b) in pabs {
41+
if p == 1 {
42+
let same = uf.find(a) == uf.find(b);
43+
println!("{}", if same { "Yes" } else { "No" });
44+
} else {
45+
uf.union(a, b);
46+
}
47+
}
48+
}

examples/tests.ron

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
name: "practice contest: A - Welcome to AtCoder",
99
matching: ExactWords,
1010
),
11+
"atc001-b": (
12+
name: "ATC001: B - Union Find",
13+
matching: ExactWords,
14+
),
1115
"arc065-c": (
1216
name: "ABC049 / ARC065: C - 白昼夢 / Daydream",
1317
matching: ExactWords,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
8 9
2+
0 1 2
3+
0 3 2
4+
1 1 3
5+
1 1 4
6+
0 2 4
7+
1 4 1
8+
0 4 2
9+
0 0 0
10+
1 0 0
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Yes
2+
No
3+
Yes
4+
Yes

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy