結果
| 問題 |
No.697 池の数はいくつか
|
| ユーザー |
lllllll88938494
|
| 提出日時 | 2022-09-22 16:11:25 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 667 bytes |
| コンパイル時間 | 290 ms |
| コンパイル使用メモリ | 82,068 KB |
| 実行使用メモリ | 876,316 KB |
| 最終ジャッジ日時 | 2024-12-22 04:59:03 |
| 合計ジャッジ時間 | 72,295 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 MLE * 2 |
| other | AC * 17 TLE * 7 MLE * 8 |
ソースコード
from collections import deque
h,w=map(int,input().split())
grid=[list(map(int,input().split())) for i in range(h)]
f=[[0]*w for i in range(h)]
cnt = 1
l=[1,0,-1,0]
r=[0,1,0,-1]
for i in range(h):
for j in range(w):
if grid[i][j] == 1 and f[i][j] ==0:
d=deque()
d.append((i,j))
while d:
x,y=d.popleft()
f[x][y] = cnt
for k in range(4):
if 0 <= x + l[k] < h and 0 <= y + r[k] < w:
if grid[x+l[k]][y+r[k]] == 1 and f[x+l[k]][y+r[k]] == 0:
d.append((x+l[k],y+r[k]))
cnt+=1
print(cnt-1)
lllllll88938494