結果
問題 | No.179 塗り分け |
ユーザー |
![]() |
提出日時 | 2017-12-27 02:50:11 |
言語 | Crystal (1.14.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 970 bytes |
コンパイル時間 | 12,143 ms |
コンパイル使用メモリ | 295,876 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-30 19:14:29 |
合計ジャッジ時間 | 14,245 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 34 WA * 6 |
ソースコード
h, w = gets.not_nil!.split(" ").map{|x| x.to_i} rect = [] of Array(String) 1.upto(h) do |i| rect << gets.not_nil!.split("") end def ok?(rect, h, w) 0.upto(h-1) do |dy| 0.upto(w-1) do |dx| if dx == 0 && dy == 0 next end _rect = rect.clone ok = true 0.upto(h-1) do |y| 0.upto(w-1) do |x| if _rect[y][x] == "." next end ny = y + dy nx = x + dx if nx >= w || ny >= h next end if _rect[y][x] == _rect[ny][nx] _rect[y][x] = "." _rect[ny][nx] = "." else ok = false break end end end 0.upto(h-1) do |y| 0.upto(w-1) do |x| if _rect[y][x] == "#" ok = false end end end if ok return true end end end return false end puts ok?(rect, h, w) ? "YES" : "NO"