結果
問題 | No.179 塗り分け |
ユーザー |
![]() |
提出日時 | 2022-12-16 22:47:29 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 543 ms / 3,000 ms |
コード長 | 1,083 bytes |
コンパイル時間 | 15,342 ms |
コンパイル使用メモリ | 384,872 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-16 04:17:33 |
合計ジャッジ時間 | 15,621 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 40 |
ソースコード
use std::collections::VecDeque; fn main() { let mut xx = String::new(); std::io::Read::read_to_string(&mut std::io::stdin(), &mut xx).ok(); let xx: Vec<Vec<char>> = xx .split_whitespace() .skip(2) .map(|s| s.chars().collect()) .collect(); let mut blk = VecDeque::new(); for y in 0..xx.len() { for x in 0..xx[0].len() { if xx[y][x] == '#' { blk.push_back((y, x)); } } } let blk = blk; if blk.len() & 1 == 1 { println!("NO"); return; } 'outer: for i in 1..blk.len() { let (dy, dx) = (blk[i].0 - blk[0].0, blk[i].1 - blk[0].1); let mut tmp = blk.clone(); while !tmp.is_empty() { let (y, x) = tmp.pop_front().unwrap(); let moves_to = (y + dy, x + dx); if tmp.contains(&moves_to) { tmp.retain(|c| c != &moves_to); } else { continue 'outer; } } println!("YES"); return; } println!("NO"); }