結果
| 問題 | No.697 池の数はいくつか |
| ユーザー |
|
| 提出日時 | 2019-01-24 06:45:26 |
| 言語 | Nim (2.2.6) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,118 bytes |
| 記録 | |
| コンパイル時間 | 455 ms |
| コンパイル使用メモリ | 41,088 KB |
| 最終ジャッジ日時 | 2024-11-15 04:48:01 |
| 合計ジャッジ時間 | 1,789 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 17) Error: cannot open file: queues
ソースコード
import sequtils,queues
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()
const dx = [1.int32,-1.int32,0.int32,0.int32]
const dy = [0.int32,0.int32,1.int32,-1.int32]
proc check(sx,sy:int32) =
var X = initQueue[int32]()
var Y = initQueue[int32]()
X.enqueue(sx)
Y.enqueue(sy)
isWater[sx][sy] = false
while X.len() > 0:
let x = X.dequeue()
let y = Y.dequeue()
template regist(nx,ny:int) =
if isWater[nx][ny] :
X.enqueue(nx)
Y.enqueue(ny)
isWater[nx][ny] = false
if x > 0: regist(x-1,y)
if y > 0: regist(x,y-1)
if x < w-1: regist(x+1,y)
if y < h-1: regist(x,y+1)
var ans = 0
for x in 0.int32..<w.int32:
for y in 0.int32..<h.int32:
if not isWater[x][y]: continue
check(x,y)
ans += 1
echo ans