結果

問題 No.2708 Jewel holder
ユーザー n_nan_na
提出日時 2024-04-01 16:13:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 585 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,060 KB
最終ジャッジ日時 2024-04-01 16:13:23
合計ジャッジ時間 1,734 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 37 ms
53,460 KB
testcase_07 AC 36 ms
53,460 KB
testcase_08 AC 37 ms
53,460 KB
testcase_09 AC 38 ms
53,460 KB
testcase_10 AC 39 ms
53,460 KB
testcase_11 AC 37 ms
53,460 KB
testcase_12 AC 36 ms
53,460 KB
testcase_13 AC 39 ms
53,460 KB
testcase_14 AC 37 ms
53,460 KB
testcase_15 AC 38 ms
53,460 KB
testcase_16 AC 36 ms
53,460 KB
testcase_17 AC 90 ms
76,060 KB
testcase_18 AC 37 ms
53,460 KB
testcase_19 AC 38 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def rec(cy,cx,cc):
    if A[cy][cx] == "o":
        nc = cc + 1
    else:
        if cc == 0:
            return
        else:
            nc = cc - 1
    if cy == H-1 and cx == W-1:
        res[0] += 1
        return
        
    for i in range(2):
        ny,nx = cy +dy[i],cx+dx[i]
        if not (0 <= ny < H and 0 <= nx < W):
            continue
        if A[ny][nx] == "#":
            continue
        rec(ny,nx,nc)
        


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

dy = (0,1)
dx = (1,0)

res = [0]
rec(0,0,0)

print(res[0])
0