Submission #62270526
Source Code Expand
use std::collections::BTreeSet; #[allow(unused_imports)] use itertools::Itertools; use proconio::input; use proconio::marker::Usize1; fn main() { input!{ n: usize, q: usize, } let mut set = BTreeSet::new(); let mut count = vec![1; n]; let mut pos = (0..n).collect_vec(); for _ in 0..q { input! { t: u8, } if t == 1 { input! { p: Usize1, h: Usize1 } let before = pos[p]; count[before] -= 1; if count[before] == 1 { set.remove(&before); } pos[p] = h; count[h] += 1; if count[h] == 2 { set.insert(h); } } else { println!("{}", set.len()); } } } pub trait Debuggable { fn debug_string(&self) -> String; } impl<T: std::fmt::Debug + std::fmt::Display> Debuggable for Vec<T> { fn debug_string(&self) -> String { use itertools::Itertools; use std::iter::repeat; if let Some(max_size) = self.iter() .enumerate() .map(|(i, x)| (format!("{:?}", x).len()).max(format!("{:?}", i).len())) .max() { let mut idx = String::from("idx |"); let mut val = String::from("val |"); for (i, xi) in self.iter().enumerate() { idx.push_str( &format!(" {:>w$} |", i, w=max_size) ); val.push_str( &format!(" {:>w$} |", xi, w=max_size) ); } format!("{}\n{}\n{}\n", idx, repeat('-').take(idx.len()).join(""), val) } else { format!("idx | \nval |\n") } } } impl<T: std::fmt::Debug + std::fmt::Display> Debuggable for std::collections::BTreeSet<T> { fn debug_string(&self) -> String { use itertools::Itertools; format!("{{ {} }}", self.iter().join(", ")) } } impl<T, U> Debuggable for std::collections::BTreeMap<T, U> where T: std::fmt::Debug + std::fmt::Display, U: std::fmt::Debug + std::fmt::Display { fn debug_string(&self) -> String { use itertools::Itertools; format!( "{{\n{}\n }}", self.iter() .map(|(k, v)| format!("{k} -> {v}, ")) .join("\n") ) } } // lg! マクロの定義 #[macro_export] macro_rules! lg { ($val:expr) => { #[cfg(feature = "local")] { { use Debuggable; let val = &$val; eprintln!( "[{}:{}] {} = \n{}", file!(), line!(), stringify!($val), val.debug_string() ); val } } } }
Submission Info
Submission Time | |
---|---|
Task | C - Pigeonhole Query |
User | ardRiriy |
Language | Rust (rustc 1.70.0) |
Score | 300 |
Code Size | 2936 Byte |
Status | AC |
Exec Time | 266 ms |
Memory | 21112 KiB |
Compile Error
warning: the item `Itertools` is imported redundantly --> src/main.rs:49:13 | 3 | use itertools::Itertools; | -------------------- the item `Itertools` is already imported here ... 49 | use itertools::Itertools; | ^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: the item `Itertools` is imported redundantly --> src/main.rs:75:13 | 3 | use itertools::Itertools; | -------------------- the item `Itertools` is already imported here ... 75 | use itertools::Itertools; | ^^^^^^^^^^^^^^^^^^^^ warning: the item `Itertools` is imported redundantly --> src/main.rs:84:13 | 3 | use itertools::Itertools; | -------------------- the item `Itertools` is already imported here ... 84 | use itertools::Itertools; | ^^^^^^^^^^^^^^^^^^^^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_00.txt, 00_sample_01.txt |
All | 00_sample_00.txt, 00_sample_01.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt, 01_test_33.txt, 01_test_34.txt, 01_test_35.txt, 01_test_36.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 1 ms | 1872 KiB |
00_sample_01.txt | AC | 0 ms | 1936 KiB |
01_test_00.txt | AC | 0 ms | 1736 KiB |
01_test_01.txt | AC | 0 ms | 1920 KiB |
01_test_02.txt | AC | 1 ms | 1936 KiB |
01_test_03.txt | AC | 4 ms | 2084 KiB |
01_test_04.txt | AC | 44 ms | 4188 KiB |
01_test_05.txt | AC | 101 ms | 3356 KiB |
01_test_06.txt | AC | 266 ms | 2532 KiB |
01_test_07.txt | AC | 265 ms | 14120 KiB |
01_test_08.txt | AC | 242 ms | 2888 KiB |
01_test_09.txt | AC | 252 ms | 15028 KiB |
01_test_10.txt | AC | 221 ms | 3196 KiB |
01_test_11.txt | AC | 233 ms | 15792 KiB |
01_test_12.txt | AC | 197 ms | 3340 KiB |
01_test_13.txt | AC | 216 ms | 16440 KiB |
01_test_14.txt | AC | 174 ms | 3460 KiB |
01_test_15.txt | AC | 197 ms | 17340 KiB |
01_test_16.txt | AC | 152 ms | 3700 KiB |
01_test_17.txt | AC | 179 ms | 18112 KiB |
01_test_18.txt | AC | 127 ms | 4096 KiB |
01_test_19.txt | AC | 161 ms | 18808 KiB |
01_test_20.txt | AC | 103 ms | 4188 KiB |
01_test_21.txt | AC | 139 ms | 19340 KiB |
01_test_22.txt | AC | 79 ms | 4452 KiB |
01_test_23.txt | AC | 119 ms | 19592 KiB |
01_test_24.txt | AC | 55 ms | 4668 KiB |
01_test_25.txt | AC | 98 ms | 20440 KiB |
01_test_26.txt | AC | 28 ms | 4948 KiB |
01_test_27.txt | AC | 76 ms | 21112 KiB |
01_test_28.txt | AC | 150 ms | 3736 KiB |
01_test_29.txt | AC | 179 ms | 17944 KiB |
01_test_30.txt | AC | 150 ms | 3872 KiB |
01_test_31.txt | AC | 178 ms | 18068 KiB |
01_test_32.txt | AC | 151 ms | 3732 KiB |
01_test_33.txt | AC | 178 ms | 18012 KiB |
01_test_34.txt | AC | 177 ms | 18560 KiB |
01_test_35.txt | AC | 161 ms | 16212 KiB |
01_test_36.txt | AC | 156 ms | 16140 KiB |