結果
| 問題 |
No.697 池の数はいくつか
|
| ユーザー |
|
| 提出日時 | 2018-06-15 22:16:58 |
| 言語 | Ruby (3.4.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 462 bytes |
| コンパイル時間 | 552 ms |
| コンパイル使用メモリ | 7,296 KB |
| 実行使用メモリ | 97,664 KB |
| 最終ジャッジ日時 | 2024-11-25 13:41:00 |
| 合計ジャッジ時間 | 44,787 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 RE * 2 TLE * 4 |
コンパイルメッセージ
Syntax OK
ソースコード
H, W = gets.split.map &:to_i
board = $<.map{|s|s.split.join.to_i(2)}
used = H.times.map{[false] * W}
DIRS = [[0, 1], [0, -1], [1, 0], [-1, 0]]
f = ->y, x{
return if !y.between?(0, H-1)
return if !x.between?(0, W-1)
return if board[y][x] == 0
return if used[y][x]
used[y][x] = true
DIRS.each{|dy, dx|
f[y+dy, x+dx]
}
}
ans = 0
H.times{|i|
W.times{|j|
next if board[i][j] == 0
next if used[i][j]
ans += 1
f[i, j]
}
}
p ans