Skip to content

Commit 3a1174f

Browse files
committed
Add examples/library-checker-unionfind.rs
1 parent faf6ba0 commit 3a1174f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

examples/library-checker-unionfind.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#[macro_use]
2+
extern crate input as _;
3+
4+
use ac_library_rs::dsu::Dsu;
5+
6+
fn main() {
7+
input! {
8+
n: usize,
9+
queries: [(u8, usize, usize)],
10+
}
11+
12+
let mut dsu = Dsu::new(n);
13+
for (kind, u, v) in queries {
14+
match kind {
15+
0 => {
16+
dsu.merge(u, v);
17+
}
18+
1 => println!("{}", u8::from(dsu.same(u, v))),
19+
_ => unreachable!(),
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)