結果

問題 No.697 池の数はいくつか
ユーザー Mr.Fuku
提出日時 2018-06-23 21:26:18
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 506 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 87,680 KB
最終ジャッジ日時 2024-11-25 13:51:32
合計ジャッジ時間 35,556 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

h,w = input().split()
h,w = int(h),int(w)

lst = []
cnt = 0

def tansaku(x,y):
    if lst[x][y]==0:
        return
    lst[x][y]=0
    tansaku(x+1,y)
    tansaku(x-1,y)
    tansaku(x,y+1)
    tansaku(x,y-1)

for a in range(h):
    l = [0]
    for b in input().split():
        l.append(int(b))
    l.append(0)
    lst.append(l)
lst.insert(0,[0]*(w+2))
lst.append([0]*(w+2))

for a in range(1,h+1):
    for b in range(1,w+1):
        if lst[a][b]==1:
            cnt+=1
            tansaku(a,b)

print(cnt)
0