結果
問題 | No.2946 Puyo |
ユーザー |
|
提出日時 | 2024-11-12 16:32:50 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 70 ms / 2,000 ms |
コード長 | 1,513 bytes |
コンパイル時間 | 29,093 ms |
コンパイル使用メモリ | 401,428 KB |
実行使用メモリ | 11,904 KB |
最終ジャッジ日時 | 2024-11-12 16:33:24 |
合計ジャッジ時間 | 17,462 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
コンパイルメッセージ
warning: unused variable: `cc` --> src/main.rs:22:21 | 22 | let mut cc = 0; | ^^ help: if this is intentional, prefix it with an underscore: `_cc` | = note: `#[warn(unused_variables)]` on by default warning: variable does not need to be mutable --> src/main.rs:22:17 | 22 | let mut cc = 0; | ----^^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default warning: type alias `Map` is never used --> src/main.rs:5:6 | 5 | type Map<K, V> = BTreeMap<K, V>; | ^^^ | = note: `#[warn(dead_code)]` on by default warning: type alias `Set` is never used --> src/main.rs:6:6 | 6 | type Set<T> = BTreeSet<T>; | ^^^
ソースコード
use proconio::{input, marker::Chars}; use std::collections::*; type Map<K, V> = BTreeMap<K, V>; type Set<T> = BTreeSet<T>; type Deque<T> = VecDeque<T>; fn main() { input! { h: usize, w: usize, g: [Chars; h] } let mut seen = vec![vec![false; w]; h]; let mut ans = vec![vec!['$'; w]; h]; for i in 0..h { for j in 0..w { if seen[i][j] || g[i][j] == '.' { continue; } let mut cc = 0; let mut que = Deque::new(); que.push_back((i, j)); let mut his = Vec::new(); while let Some((x, y)) = que.pop_front() { for &(dx, dy) in [(0, 1), (1, 0), (0, !0), (!0, 0)].iter() { let (x, y) = (x + dx, y + dy); if x < h && y < w { if !seen[x][y] && g[x][y] == g[i][j] { seen[x][y] = true; his.push((x, y)); que.push_back((x, y)); } } } } if his.len() >= 4 { while let Some((x, y)) = his.pop() { ans[x][y] = '.'; } } } } for i in 0..h { for j in 0..w { if ans[i][j] == '$' { ans[i][j] = g[i][j]; } } } for i in 0..h { println!("{}", ans[i].iter().collect::<String>()); } }