結果

問題 No.2708 Jewel holder
ユーザー playerplayer
提出日時 2024-04-04 00:23:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 1,020 bytes
コンパイル時間 442 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 70,864 KB
最終ジャッジ日時 2024-04-04 00:23:20
合計ジャッジ時間 2,296 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 38 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 45 ms
61,992 KB
testcase_08 AC 50 ms
64,088 KB
testcase_09 AC 49 ms
64,100 KB
testcase_10 AC 48 ms
62,000 KB
testcase_11 AC 51 ms
64,092 KB
testcase_12 AC 40 ms
59,508 KB
testcase_13 AC 52 ms
64,084 KB
testcase_14 AC 48 ms
64,100 KB
testcase_15 AC 56 ms
66,184 KB
testcase_16 AC 46 ms
62,000 KB
testcase_17 AC 62 ms
70,864 KB
testcase_18 AC 60 ms
68,264 KB
testcase_19 AC 63 ms
70,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

dp = [[[0 for _ in range(101)] for _ in range(w)] for _ in range(h)]
dp[0][0][1] = 1

for i in range(h):
    for j in range(w):  # start position
        if a[i][j] == "#":
            continue
        for k in range(100):
            if i + 1 < h:
                if a[i + 1][j] == "x":
                    if k > 0:
                        dp[i + 1][j][k - 1] += dp[i][j][k]
                if a[i + 1][j] == "o":
                    dp[i + 1][j][k + 1] += dp[i][j][k]
            if j + 1 < w:
                if a[i][j + 1] == "x":
                    if k > 0:
                        dp[i][j + 1][k - 1] += dp[i][j][k]
                if a[i][j + 1] == "o":
                    dp[i][j + 1][k + 1] += dp[i][j][k]

ans = 0
# print(dp[h - 1][w - 1][0])
for i in range(101):
    ans += dp[h - 1][w - 1][i]

# print(dp[0][1])
# print(dp[1][2])
# print(dp[2][1])
# print(dp[2][2])

# print(dp[0][2])
# print(dp[1][2])
# print(dp[2][1])

print(ans)
0