Submission #59869623
Source Code Expand
use ac_library::{dsu, Dsu}; use itertools::Itertools; use proconio::{input, marker::Usize1}; fn main() { input! { n: usize, q: usize, } let mut uf = Dsu::new(n); let mut color = (0..n).collect_vec(); let mut r = (0..n).map(|i| (i, i)).collect_vec(); let mut ans = vec![1; n]; for _ in 0..q { input! { t: u8, } match t { 1 => { input! { x: Usize1, c: Usize1, } ans[color[uf.leader(x)]] -= uf.size(x); ans[c] += uf.size(x); color[uf.leader(x)] = c; // 右へ let mut right = r[uf.leader(x)].1; let mut left = r[uf.leader(x)].0; while right + 1 < n && color[uf.leader(right + 1)] == c { let max_r = r[uf.leader(right + 1)].1; uf.merge(right, right + 1); right = max_r; r[uf.leader(x)] = (left, right); } while left >= 1 && color[uf.leader(left - 1)] == c { let max_l = r[uf.leader(left - 1)].0; uf.merge(left, left - 1); left = max_l; r[uf.leader(x)] = (left, right); } } 2 => { input! { c: Usize1, } println!("{}", ans[c]); } _ => { unreachable!() } } } }
Submission Info
Submission Time | |
---|---|
Task | E - 1D Bucket Tool |
User | ardRiriy |
Language | Rust (rustc 1.70.0) |
Score | 450 |
Code Size | 1601 Byte |
Status | AC |
Exec Time | 180 ms |
Memory | 22444 KiB |
Compile Error
warning: unused import: `dsu` --> src/main.rs:1:18 | 1 | use ac_library::{dsu, Dsu}; | ^^^ | = note: `#[warn(unused_imports)]` on by default
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 450 / 450 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt |
All | hand.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, sample_01.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
hand.txt | AC | 1 ms | 1856 KiB |
random_01.txt | AC | 97 ms | 3012 KiB |
random_02.txt | AC | 151 ms | 2716 KiB |
random_03.txt | AC | 165 ms | 2988 KiB |
random_04.txt | AC | 180 ms | 2900 KiB |
random_05.txt | AC | 22 ms | 21500 KiB |
random_06.txt | AC | 25 ms | 22444 KiB |
random_07.txt | AC | 78 ms | 21072 KiB |
random_08.txt | AC | 140 ms | 21640 KiB |
random_09.txt | AC | 137 ms | 21860 KiB |
random_10.txt | AC | 138 ms | 21796 KiB |
random_11.txt | AC | 137 ms | 21792 KiB |
random_12.txt | AC | 136 ms | 21764 KiB |
random_13.txt | AC | 108 ms | 4868 KiB |
random_14.txt | AC | 109 ms | 4884 KiB |
random_15.txt | AC | 108 ms | 4928 KiB |
random_16.txt | AC | 109 ms | 4912 KiB |
sample_01.txt | AC | 1 ms | 1736 KiB |