結果
問題 |
No.697 池の数はいくつか
|
ユーザー |
![]() |
提出日時 | 2023-10-12 02:21:06 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 539 bytes |
コンパイル時間 | 742 ms |
コンパイル使用メモリ | 82,060 KB |
実行使用メモリ | 513,504 KB |
最終ジャッジ日時 | 2024-09-14 02:09:11 |
合計ジャッジ時間 | 16,070 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 MLE * 2 |
ソースコード
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)