結果
| 問題 |
No.697 池の数はいくつか
|
| ユーザー |
titia
|
| 提出日時 | 2023-10-12 02:20:17 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 539 bytes |
| コンパイル時間 | 984 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 377,856 KB |
| 最終ジャッジ日時 | 2024-09-14 02:08:18 |
| 合計ジャッジ時間 | 19,987 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 MLE * 1 |
| other | AC * 26 TLE * 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