結果

問題 No.697 池の数はいくつか
ユーザー ああいいああいい
提出日時 2022-03-07 19:56:42
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 576 bytes
コンパイル時間 1,585 ms
コンパイル使用メモリ 86,660 KB
実行使用メモリ 473,400 KB
最終ジャッジ日時 2023-09-29 21:10:01
合計ジャッジ時間 16,565 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,164 KB
testcase_01 AC 69 ms
71,028 KB
testcase_02 AC 69 ms
70,800 KB
testcase_03 AC 71 ms
71,268 KB
testcase_04 AC 73 ms
71,004 KB
testcase_05 AC 72 ms
71,024 KB
testcase_06 AC 73 ms
71,228 KB
testcase_07 AC 73 ms
71,140 KB
testcase_08 AC 73 ms
71,120 KB
testcase_09 AC 72 ms
71,240 KB
testcase_10 AC 74 ms
71,036 KB
testcase_11 AC 74 ms
71,256 KB
testcase_12 AC 70 ms
71,044 KB
testcase_13 AC 73 ms
71,040 KB
testcase_14 AC 74 ms
70,796 KB
testcase_15 AC 73 ms
71,044 KB
testcase_16 AC 73 ms
71,224 KB
testcase_17 AC 73 ms
70,804 KB
testcase_18 AC 74 ms
71,336 KB
testcase_19 AC 73 ms
71,268 KB
testcase_20 AC 74 ms
71,032 KB
testcase_21 AC 74 ms
70,748 KB
testcase_22 AC 74 ms
71,260 KB
testcase_23 AC 70 ms
71,224 KB
testcase_24 AC 234 ms
86,656 KB
testcase_25 AC 222 ms
86,700 KB
testcase_26 AC 221 ms
86,804 KB
testcase_27 AC 234 ms
86,608 KB
testcase_28 AC 225 ms
86,728 KB
testcase_29 MLE -
testcase_30 AC 1,297 ms
167,276 KB
testcase_31 MLE -
testcase_32 AC 1,093 ms
167,668 KB
testcase_33 AC 1,190 ms
167,676 KB
testcase_34 AC 1,111 ms
167,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]

count = 0
stack = []
for h in range(H):
    for w in range(W):
        if A[h][w] == 1:
            count += 1
            stack.append((h,w))
            A[h][w] = 0
            while stack:
                x,y = stack.pop()
                for i,j in [(0,1),(0,-1),(1,0),(-1,0)]:
                    if 0 <= x + i < H and 0 <= y + j < W:
                        if A[x+i][y+j]:
                            A[x+i][y+j] = 0
                            stack.append((x+i,y+j))
print(count)
0