結果
| 問題 |
No.2708 Jewel holder
|
| コンテスト | |
| ユーザー |
navel_tos
|
| 提出日時 | 2024-03-31 16:24:25 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 54 ms / 2,000 ms |
| コード長 | 827 bytes |
| コンパイル時間 | 359 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 64,512 KB |
| 最終ジャッジ日時 | 2024-09-30 21:05:04 |
| 合計ジャッジ時間 | 1,820 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#MMA Contest 018 C
H, W = map(int, input().split())
A = [input() for _ in range(H)]
#DP[h][w][c]: A[h][w]に到達し、進入処理を終えた後、宝石をc個所持
DP = [[[0] * (H + W + 1) for w in range(W)] for h in range(H)]
DP[0][0][1] = 1
for h in range(H):
for w in range(W):
for c in range(H + W + 1):
for x, y in [(h + 1, w), (h, w + 1)]:
if x not in range(H) or y not in range(W):
continue
if A[x][y] == '#':
continue
if A[x][y] == 'o':
if c < H + W:
DP[x][y][c + 1] += DP[h][w][c]
if A[x][y] == 'x':
if c > 0:
DP[x][y][c - 1] += DP[h][w][c]
print(sum(DP[-1][-1][c] for c in range(H + W + 1)))
navel_tos