結果
| 問題 | No.697 池の数はいくつか |
| ユーザー |
titia
|
| 提出日時 | 2023-10-12 02:20:17 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 539 bytes |
| 記録 | |
| コンパイル時間 | 465 ms |
| コンパイル使用メモリ | 20,840 KB |
| 実行使用メモリ | 625,372 KB |
| 最終ジャッジ日時 | 2026-04-04 09:29:18 |
| 合計ジャッジ時間 | 17,089 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge5_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 MLE * 1 -- * 5 |
ソースコード
H,W=map(int,input().split())
A=[list(map(int,input().split())) for i in range(H)]
ANS=0
USE=[[0]*W for i in range(H)]
for i in range(H):
for j in range(W):
if A[i][j]==1 and USE[i][j]==0:
ANS+=1
Q=[(i,j)]
USE[i][j]=1
while Q:
x,y=Q.pop()
for z,w in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]:
if 0<=z<H and 0<=w<W and A[z][w]==1 and USE[z][w]==0:
USE[z][w]=1
Q.append((z,w))
print(ANS)
titia