結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,012 KB
testcase_01 AC 3 ms
5,092 KB
testcase_02 AC 2 ms
5,000 KB
testcase_03 AC 2 ms
5,068 KB
testcase_04 AC 3 ms
5,040 KB
testcase_05 AC 2 ms
5,036 KB
testcase_06 AC 2 ms
5,000 KB
testcase_07 AC 2 ms
5,080 KB
testcase_08 AC 2 ms
5,048 KB
testcase_09 AC 2 ms
5,020 KB
testcase_10 AC 2 ms
5,028 KB
testcase_11 AC 2 ms
4,996 KB
testcase_12 AC 2 ms
5,032 KB
testcase_13 AC 2 ms
5,088 KB
testcase_14 AC 2 ms
4,960 KB
testcase_15 AC 2 ms
5,092 KB
testcase_16 AC 2 ms
5,020 KB
testcase_17 AC 2 ms
5,008 KB
testcase_18 AC 2 ms
5,056 KB
testcase_19 AC 2 ms
5,000 KB
testcase_20 AC 2 ms
5,044 KB
testcase_21 AC 2 ms
5,064 KB
testcase_22 AC 2 ms
5,036 KB
testcase_23 AC 2 ms
4,964 KB
testcase_24 AC 46 ms
10,016 KB
testcase_25 AC 46 ms
9,972 KB
testcase_26 AC 48 ms
10,048 KB
testcase_27 AC 46 ms
10,072 KB
testcase_28 AC 46 ms
9,996 KB
testcase_29 MLE -
testcase_30 AC 389 ms
20,600 KB
testcase_31 MLE -
testcase_32 AC 398 ms
20,580 KB
testcase_33 AC 402 ms
20,568 KB
testcase_34 AC 398 ms
20,540 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*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
0