結果
| 問題 |
No.697 池の数はいくつか
|
| ユーザー |
|
| 提出日時 | 2019-01-24 05:51:13 |
| 言語 | Nim (2.2.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 961 bytes |
| コンパイル時間 | 2,826 ms |
| コンパイル使用メモリ | 60,972 KB |
| 実行使用メモリ | 723,548 KB |
| 最終ジャッジ日時 | 2024-11-25 14:35:12 |
| 合計ジャッジ時間 | 8,597 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 MLE * 2 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]
ソースコード
import sequtils
proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
while true:
let k = getchar_unlocked()
if k < '0': break
result = 10 * result + k.ord - '0'.ord
let h = scan()
let w = scan()
var isWater : array[3001,array[3001,bool]]
for y in 0..<h:
for x in 0..<w:
isWater[x][y] = getchar_unlocked() == '1'
discard getchar_unlocked()
var checked : array[3001,array[3001,bool]]
proc check(x,y:int) : bool =
if checked[x][y] : return false
if not isWater[x][y]: return false
checked[x][y] = true
const dxdy4 :seq[tuple[x,y:int]] = @[(0,1),(1,0),(0,-1),(-1,0)]
for d in dxdy4:
let (nx,ny) = (x+d.x,y+d.y)
if nx < 0 or nx >= w : continue
if ny < 0 or ny >= h : continue
if checked[nx][ny] : continue
if not isWater[nx][ny] : continue
discard check(nx,ny)
return true
var ans = 0
for x in 0..<w:
for y in 0..<h:
if check(x,y) : ans += 1
echo ans