結果
問題 | No.307 最近色塗る問題多くない? |
ユーザー |
![]() |
提出日時 | 2015-11-27 23:55:38 |
言語 | Ruby (3.4.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 885 bytes |
コンパイル時間 | 276 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 86,200 KB |
最終ジャッジ日時 | 2024-09-14 01:33:40 |
合計ジャッジ時間 | 6,768 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 TLE * 1 -- * 28 |
コンパイルメッセージ
Syntax OK
ソースコード
h, w = gets.split(' ').map(&:to_i)map = []h.times domap.push(gets.split(' ').map(&:to_i))endqueue = []gets.to_i.times dohh, ww, n = gets.split(' ').map(&:to_i)hh -= 1ww -= 1c = map[hh][ww]map[hh][ww] = nnext if c == nqueue.push([hh-1, ww]) if hh > 0 and map[hh-1][ww] == cqueue.push([hh+1, ww]) if hh < h-1 and map[hh+1][ww] == cqueue.push([hh, ww-1]) if ww > 0 and map[hh][ww-1] == cqueue.push([hh, ww+1]) if ww < w-1 and map[hh][ww+1] == cwhile queue.empty?.! dohhh, www = queue.popmap[hhh][www] = nqueue.push([hhh-1, www]) if hhh > 0 and map[hhh-1][www] == cqueue.push([hhh+1, www]) if hhh < h-1 and map[hhh+1][www] == cqueue.push([hhh, www-1]) if www > 0 and map[hhh][www-1] == cqueue.push([hhh, www+1]) if www < w-1 and map[hhh][www+1] == cqueue.uniq!endendmap.each do |m|puts m.join(' ')end