結果
問題 | No.697 池の数はいくつか |
ユーザー |
![]() |
提出日時 | 2023-10-12 02:27:48 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
MLE
|
実行時間 | - |
コード長 | 538 bytes |
コンパイル時間 | 81 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 332,176 KB |
最終ジャッジ日時 | 2024-09-14 02:15:04 |
合計ジャッジ時間 | 20,344 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 MLE * 1 -- * 5 |
ソースコード
H,W=map(int,input().split()) A=[] for i in range(H): A+=list(map(int,input().split())) ANS=0 USE=[0]*(H*W) for i in range(H): for j in range(W): if A[i*W+j]==1 and USE[i*W+j]==0: ANS+=1 Q=[(i,j)] USE[i*W+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+w]==1 and USE[z*W+w]==0: USE[z*W+w]=1 Q.append((z,w)) print(ANS)