結果

問題 No.697 池の数はいくつか
ユーザー kawacchukawacchu
提出日時 2019-09-16 19:51:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 692 bytes
コンパイル時間 124 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 92,928 KB
最終ジャッジ日時 2024-05-04 06:44:30
合計ジャッジ時間 17,116 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,880 KB
testcase_01 AC 25 ms
10,624 KB
testcase_02 AC 26 ms
10,624 KB
testcase_03 AC 25 ms
10,624 KB
testcase_04 AC 25 ms
10,880 KB
testcase_05 AC 26 ms
10,752 KB
testcase_06 AC 26 ms
10,624 KB
testcase_07 AC 26 ms
10,880 KB
testcase_08 AC 27 ms
10,624 KB
testcase_09 AC 25 ms
10,624 KB
testcase_10 AC 24 ms
10,880 KB
testcase_11 AC 24 ms
10,880 KB
testcase_12 AC 25 ms
10,752 KB
testcase_13 AC 25 ms
10,752 KB
testcase_14 AC 24 ms
10,752 KB
testcase_15 AC 25 ms
10,880 KB
testcase_16 AC 24 ms
10,880 KB
testcase_17 AC 25 ms
10,752 KB
testcase_18 AC 27 ms
10,752 KB
testcase_19 AC 27 ms
10,752 KB
testcase_20 AC 27 ms
10,880 KB
testcase_21 AC 25 ms
10,752 KB
testcase_22 AC 26 ms
10,752 KB
testcase_23 AC 27 ms
10,752 KB
testcase_24 AC 1,435 ms
19,712 KB
testcase_25 AC 1,472 ms
19,712 KB
testcase_26 AC 1,451 ms
19,584 KB
testcase_27 AC 1,440 ms
19,712 KB
testcase_28 AC 1,434 ms
19,584 KB
testcase_29 TLE -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import deque
H,W = map(int,input().split())
A = [list(map(int,input().split())) for y in range(H)]
ans = 0
dxy = [(-1,0), (0,-1), (0,1), (1,0)]
for i in range(H) :
    for j in range(W) :
        if A[i][j] != 1 :
            continue
        ans += 1
        A[i][j] = 0
        q = deque([(i, j)])
        while q :
            y, x = q.popleft()
            for dy,dx in dxy :
                ny,nx = y+dy, x+dx
                if ny<0 or ny>=H or nx<0 or nx>=W :
                    continue
                if A[ny][nx] != 1 :
                    continue
                q.append((ny, nx))
                A[ny][nx] = 0
print(ans)
0