結果
| 問題 | 
                            No.697 池の数はいくつか
                             | 
                    
| ユーザー | 
                            👑  Kazun
                         | 
                    
| 提出日時 | 2020-07-18 01:30:03 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                MLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 601 bytes | 
| コンパイル時間 | 166 ms | 
| コンパイル使用メモリ | 82,444 KB | 
| 実行使用メモリ | 849,388 KB | 
| 最終ジャッジ日時 | 2024-11-25 16:21:52 | 
| 合計ジャッジ時間 | 70,307 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | MLE * 3 | 
| other | AC * 19 TLE * 6 MLE * 7 | 
ソースコード
from collections import deque
H,W=map(int,input().split())
A=[[0]*(W) for _ in range(H)]
for y in range(H):
    B=list(map(int,input().split()))
    A[y]=B
V=[(-1,0),(1,0),(0,-1),(0,1)]
X=0
for y in range(H):
    for x in range(W):
        if A[y][x]==1:
            X+=1
            Q=deque([(x,y)])
            while Q:
                p,q=Q.popleft()
                A[q][p]=0
                for a,b in V:
                    s=p+a
                    t=q+b
                    if 0<=s<W and 0<=t<H:
                        if A[t][s]==1:
                            Q.append((s,t))
print(X)
            
            
            
        
            
Kazun