結果

問題 No.697 池の数はいくつか
ユーザー むらためむらため
提出日時 2019-01-24 05:51:13
言語 Nim
(2.0.2)
結果
MLE  
実行時間 -
コード長 961 bytes
コンパイル時間 3,330 ms
コンパイル使用メモリ 61,348 KB
実行使用メモリ 723,544 KB
最終ジャッジ日時 2024-05-04 06:21:14
合計ジャッジ時間 8,409 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 1 ms
6,940 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 43 ms
9,948 KB
testcase_25 AC 45 ms
9,948 KB
testcase_26 AC 47 ms
9,944 KB
testcase_27 AC 49 ms
9,944 KB
testcase_28 AC 49 ms
9,940 KB
testcase_29 MLE -
testcase_30 AC 377 ms
20,308 KB
testcase_31 MLE -
testcase_32 AC 383 ms
20,440 KB
testcase_33 AC 397 ms
20,568 KB
testcase_34 AC 383 ms
20,436 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]

ソースコード

diff #

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
0