結果
| 問題 |
No.697 池の数はいくつか
|
| ユーザー |
kawacchu
|
| 提出日時 | 2019-09-16 19:51:09 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 692 bytes |
| コンパイル時間 | 198 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 97,920 KB |
| 最終ジャッジ日時 | 2024-11-25 15:24:54 |
| 合計ジャッジ時間 | 52,795 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 TLE * 6 |
ソースコード
import sys
input = sys.stdin.readline
from collections import deque
H,W = map(int,input().split())
A = [list(map(int,input().split())) for y in range(H)]
ans = 0
dxy = [(-1,0), (0,-1), (0,1), (1,0)]
for i in range(H) :
for j in range(W) :
if A[i][j] != 1 :
continue
ans += 1
A[i][j] = 0
q = deque([(i, j)])
while q :
y, x = q.popleft()
for dy,dx in dxy :
ny,nx = y+dy, x+dx
if ny<0 or ny>=H or nx<0 or nx>=W :
continue
if A[ny][nx] != 1 :
continue
q.append((ny, nx))
A[ny][nx] = 0
print(ans)
kawacchu