結果
| 問題 | No.697 池の数はいくつか |
| ユーザー |
AEn
|
| 提出日時 | 2022-05-26 18:06:41 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
MLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 796 bytes |
| 記録 | |
| コンパイル時間 | 353 ms |
| コンパイル使用メモリ | 85,632 KB |
| 実行使用メモリ | 310,144 KB |
| 最終ジャッジ日時 | 2026-05-08 14:58:03 |
| 合計ジャッジ時間 | 13,384 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 MLE * 2 |
ソースコード
from collections import deque
H, W = map(int, input().split())
m = []
for i in range(H):
m.append(list(map(int, input().split())))
xx = [1, 0, -1, 0]
yy = [0, 1, 0, -1]
q = deque()
cnt = 0
seen = [[False]*W for _ in range(H)]
for i in range(H):
for j in range(W):
if seen[i][j] == False and m[i][j] == 1:
seen[i][j] = True
q.append((i, j))
cnt += 1
while q:
x, y = q.popleft()
for px, py in zip(xx, yy):
cx = x+px
cy = y+py
if 0<=cx<H and 0<=cy<W and m[cx][cy] == 1 and seen[cx][cy] == False:
q.append((cx, cy))
seen[cx][cy] = True
else:
seen[i][j] = True
print(cnt)
AEn