結果

問題 No.2708 Jewel holder
ユーザー pyt-314
提出日時 2024-03-31 14:49:50
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 765 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-09-30 20:00:11
合計ジャッジ時間 1,322 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, input().split())
world = []
for i in range(H):
    world.append(list(e for e in input()))
# print(world)

chash = dict()


def how_much(h, w, state):
    global H, W, chash, world
    if h == H & w == W:
        return 1
    if h > H or w > W:
        return 0
    if world[h - 1][w - 1] == "#":
        return 0
    if world[h - 1][w - 1] == "o":
        state += 1
    if world[h - 1][w - 1] == "x":
        state -= 1
    if state <= -1:
        return 0
    # print(how_much(h + 1, w) + how_much(h, w + 1))
    if (h, w) not in chash.keys():
        chash["x:{},y:{}".format(h, w)] = how_much(h + 1, w, state) + how_much(
            h, w + 1, state
        )
    return chash["x:{},y:{}".format(h, w)]


# print(chash)
print(how_much(1, 1, 0))
0