結果
| 問題 |
No.697 池の数はいくつか
|
| ユーザー |
|
| 提出日時 | 2019-01-24 05:53:41 |
| 言語 | Nim (2.2.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,016 bytes |
| コンパイル時間 | 2,360 ms |
| コンパイル使用メモリ | 60,868 KB |
| 実行使用メモリ | 814,040 KB |
| 最終ジャッジ日時 | 2024-11-25 14:35:24 |
| 合計ジャッジ時間 | 9,000 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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*3001,bool]
var checked : array[3001*3001,bool]
# var isWater : array[3001,array[3001,bool]]
for y in 0..<h:
for x in 0..<w:
isWater[x*3001+y] = getchar_unlocked() == '1'
discard getchar_unlocked()
proc check(x,y:int) : bool =
if checked[x*3001+y] : return false
if not isWater[x*3001+y]: return false
checked[x*3001+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*3001+ny] : continue
if not isWater[nx*3001+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