結果
| 問題 | 
                            No.179 塗り分け
                             | 
                    
| コンテスト | |
| ユーザー | 
                             d2verb
                         | 
                    
| 提出日時 | 2017-12-27 03:16:27 | 
| 言語 | Crystal  (1.14.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 699 bytes | 
| コンパイル時間 | 11,872 ms | 
| コンパイル使用メモリ | 296,056 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-30 19:13:07 | 
| 合計ジャッジ時間 | 14,329 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 6 | 
| other | AC * 34 WA * 6 | 
コンパイルメッセージ
In Main.cr:8:16
 8 | (0...h).to_a.product((0...w).to_a) do |dy, dx|
                  ^------
Warning: Deprecated Array(Int32)#product. Use `Indexable#each_cartesian(*others : Indexable, &block)` instead
In Main.cr:13:18
 13 | (0...h).to_a.product((0...w).to_a) do |y, x|
                   ^------
Warning: Deprecated Array(Int32)#product. Use `Indexable#each_cartesian(*others : Indexable, &block)` instead
A total of 2 warnings were found.
            
            ソースコード
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...h).to_a.product((0...w).to_a) do |dy, dx|
    next if dx == 0 && dy == 0
    _rect = rect.clone
    ok = true
    (0...h).to_a.product((0...w).to_a) do |y, x|
      next if _rect[y][x] == "."
      ny = y + dy
      nx = x + dx
      if nx >= w || ny >= h
        ok = false
        break
      end
      if _rect[y][x] == _rect[ny][nx]
        _rect[y][x] = "."
        _rect[ny][nx] = "."
      else
        ok = false
        break
      end
    end
    return true if ok
  end
  return false
end
puts ok?(rect, h, w) ? "YES" : "NO"
            
            
            
        
            
d2verb