結果

問題 No.697 池の数はいくつか
ユーザー DrDrpilotDrDrpilot
提出日時 2022-04-13 16:03:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 445 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 10,796 KB
実行使用メモリ 139,364 KB
最終ジャッジ日時 2023-08-25 02:04:56
合計ジャッジ時間 18,220 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
12,236 KB
testcase_01 AC 16 ms
7,856 KB
testcase_02 AC 15 ms
7,868 KB
testcase_03 AC 15 ms
7,812 KB
testcase_04 AC 15 ms
7,860 KB
testcase_05 AC 15 ms
7,812 KB
testcase_06 AC 15 ms
7,960 KB
testcase_07 AC 15 ms
7,808 KB
testcase_08 AC 15 ms
7,852 KB
testcase_09 AC 15 ms
7,808 KB
testcase_10 AC 15 ms
7,852 KB
testcase_11 AC 15 ms
7,856 KB
testcase_12 AC 15 ms
7,860 KB
testcase_13 AC 15 ms
7,816 KB
testcase_14 AC 15 ms
7,864 KB
testcase_15 AC 15 ms
7,804 KB
testcase_16 AC 15 ms
7,800 KB
testcase_17 AC 15 ms
7,912 KB
testcase_18 AC 15 ms
7,936 KB
testcase_19 AC 15 ms
7,856 KB
testcase_20 AC 16 ms
7,800 KB
testcase_21 AC 15 ms
7,856 KB
testcase_22 AC 15 ms
7,824 KB
testcase_23 AC 15 ms
7,864 KB
testcase_24 AC 829 ms
17,028 KB
testcase_25 AC 832 ms
17,040 KB
testcase_26 AC 827 ms
17,024 KB
testcase_27 AC 824 ms
17,020 KB
testcase_28 AC 833 ms
17,100 KB
testcase_29 RE -
testcase_30 TLE -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(100000)
h,w=map(int,input().split())
g=[list(map(int,input().split())) for _ in range(h)]
def dfs(y,x):
    g[y][x]=0
    dy=[0,1,0,-1]
    dx=[1,0,-1,0]
    for i in range(4):
        ny=y+dy[i];nx=x+dx[i]
        if 0<=ny<h and 0<=nx<w and g[ny][nx]==1:
            dfs(ny,nx)
    return 
ans=0
for i in range(h):
    for j in range(w):
        if g[i][j]==1:
            ans+=1
            dfs(i,j)
print(ans)
0