結果

問題 No.697 池の数はいくつか
ユーザー むらためむらため
提出日時 2019-01-24 05:52:12
言語 Nim
(2.0.2)
結果
MLE  
実行時間 -
コード長 916 bytes
コンパイル時間 2,385 ms
コンパイル使用メモリ 66,784 KB
実行使用メモリ 442,472 KB
最終ジャッジ日時 2023-08-16 22:59:58
合計ジャッジ時間 7,825 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,024 KB
testcase_01 AC 2 ms
5,020 KB
testcase_02 AC 2 ms
5,028 KB
testcase_03 AC 2 ms
5,096 KB
testcase_04 AC 2 ms
5,028 KB
testcase_05 AC 2 ms
5,088 KB
testcase_06 AC 2 ms
5,060 KB
testcase_07 AC 2 ms
5,024 KB
testcase_08 AC 2 ms
5,064 KB
testcase_09 AC 2 ms
5,020 KB
testcase_10 AC 2 ms
5,044 KB
testcase_11 AC 2 ms
5,032 KB
testcase_12 AC 2 ms
5,060 KB
testcase_13 AC 2 ms
5,048 KB
testcase_14 AC 2 ms
4,956 KB
testcase_15 AC 2 ms
5,032 KB
testcase_16 AC 2 ms
4,944 KB
testcase_17 AC 2 ms
5,020 KB
testcase_18 AC 2 ms
5,032 KB
testcase_19 AC 3 ms
5,064 KB
testcase_20 AC 2 ms
5,064 KB
testcase_21 AC 2 ms
4,952 KB
testcase_22 AC 3 ms
5,080 KB
testcase_23 AC 2 ms
4,964 KB
testcase_24 AC 49 ms
10,068 KB
testcase_25 AC 50 ms
10,044 KB
testcase_26 AC 50 ms
10,060 KB
testcase_27 AC 49 ms
10,012 KB
testcase_28 AC 48 ms
10,064 KB
testcase_29 MLE -
testcase_30 AC 403 ms
20,556 KB
testcase_31 MLE -
testcase_32 AC 403 ms
20,620 KB
testcase_33 AC 406 ms
20,592 KB
testcase_34 AC 402 ms
20,536 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]

ソースコード

diff #

import sequtils

proc getchar():char {. importc:"getchar",header: "<stdio.h>" .}
proc scan(): int =
  while true:
    let k = getchar()
    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() == '1'
    discard getchar()
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