結果
問題 | No.2372 既視感 |
ユーザー | rp523 |
提出日時 | 2023-07-08 00:38:31 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,557 bytes |
コンパイル時間 | 12,711 ms |
コンパイル使用メモリ | 401,712 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-21 20:59:34 |
合計ジャッジ時間 | 13,826 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,812 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,944 KB |
testcase_05 | WA | - |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 1 ms
6,940 KB |
testcase_08 | WA | - |
testcase_09 | AC | 1 ms
6,940 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 2 ms
6,944 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 1 ms
6,944 KB |
testcase_23 | AC | 3 ms
6,944 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 3 ms
6,940 KB |
testcase_28 | AC | 3 ms
6,944 KB |
ソースコード
#![allow(unused_macros, unused_imports, dead_code)] use std::any::TypeId; use std::cmp::{max, min, Ordering, Reverse}; use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque}; use std::mem::swap; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign}; mod procon_reader { use std::fmt::Debug; use std::io::Read; use std::str::FromStr; pub fn read<T: FromStr>() -> T where <T as FromStr>::Err: Debug, { let stdin = std::io::stdin(); let mut stdin_lock = stdin.lock(); let mut u8b: [u8; 1] = [0]; loop { let mut buf: Vec<u8> = Vec::with_capacity(16); loop { let res = stdin_lock.read(&mut u8b); if res.unwrap_or(0) == 0 || u8b[0] <= b' ' { break; } else { buf.push(u8b[0]); } } if !buf.is_empty() { let ret = String::from_utf8(buf).unwrap(); return ret.parse().unwrap(); } } } pub fn read_vec<T: std::str::FromStr>(n: usize) -> Vec<T> where <T as FromStr>::Err: Debug, { (0..n).map(|_| read::<T>()).collect::<Vec<T>>() } pub fn read_vec_sub1(n: usize) -> Vec<usize> { (0..n).map(|_| read::<usize>() - 1).collect::<Vec<usize>>() } pub fn read_mat<T: std::str::FromStr>(h: usize, w: usize) -> Vec<Vec<T>> where <T as FromStr>::Err: Debug, { (0..h).map(|_| read_vec::<T>(w)).collect::<Vec<Vec<T>>>() } } use procon_reader::*; ////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// fn main() { let mut que = VecDeque::new(); let mut seen = BTreeMap::new(); let n = read::<usize>(); let k = read::<usize>(); let q = read::<usize>(); let mut ans =vec![]; for _qi in 0..q { let t = read::<usize>(); if t == 1 { let s = read::<String>(); if que.len() >= n { let d = que.pop_front().unwrap(); let rem = seen[&d]; if rem == 1 { seen.remove(&d); } else { *seen.get_mut(&d).unwrap() -= 1; } } que.push_back(s.clone()); *seen.entry(s).or_insert(0) += 1; debug_assert!(que.len() <= n); continue; } let mut a = 0; let mut cum = 0; let mut ts = vec![]; for _ in 0..6 { let t = read::<String>(); let d = read::<usize>(); let need = if seen.contains_key(&t) { min(d, k) } else { d }; cum += need; if cum <= 60 { a += 1; } ts.push(t); } for t in ts { if que.len() >= n { let d = que.pop_front().unwrap(); let rem = seen[&d]; if rem == 1 { seen.remove(&d); } else { *seen.get_mut(&d).unwrap() -= 1; } } que.push_back(t.clone()); *seen.entry(t).or_insert(0) += 1; debug_assert!(que.len() <= n); } ans.push(a); } eprintln!(); for ans in ans { println!("{}", ans); } }