結果

問題 No.697 池の数はいくつか
ユーザー 👑 KazunKazun
提出日時 2020-07-18 01:30:03
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 601 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 82,728 KB
実行使用メモリ 508,896 KB
最終ジャッジ日時 2024-05-04 07:02:52
合計ジャッジ時間 13,741 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
53,888 KB
testcase_01 AC 45 ms
53,632 KB
testcase_02 AC 45 ms
53,632 KB
testcase_03 AC 45 ms
53,564 KB
testcase_04 AC 44 ms
53,888 KB
testcase_05 AC 43 ms
53,504 KB
testcase_06 AC 44 ms
53,888 KB
testcase_07 AC 42 ms
53,504 KB
testcase_08 AC 44 ms
53,632 KB
testcase_09 AC 44 ms
53,504 KB
testcase_10 AC 43 ms
54,016 KB
testcase_11 AC 44 ms
53,632 KB
testcase_12 AC 44 ms
53,632 KB
testcase_13 AC 44 ms
53,632 KB
testcase_14 AC 43 ms
53,504 KB
testcase_15 AC 43 ms
53,376 KB
testcase_16 AC 43 ms
53,760 KB
testcase_17 AC 43 ms
53,632 KB
testcase_18 AC 43 ms
53,632 KB
testcase_19 AC 43 ms
53,888 KB
testcase_20 AC 43 ms
53,632 KB
testcase_21 AC 43 ms
53,760 KB
testcase_22 AC 43 ms
53,760 KB
testcase_23 AC 44 ms
53,632 KB
testcase_24 AC 3,582 ms
291,328 KB
testcase_25 MLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0