結果
| 問題 |
No.3071 Double Speedrun
|
| コンテスト | |
| ユーザー |
PNJ
|
| 提出日時 | 2025-03-22 15:56:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 962 bytes |
| コンパイル時間 | 268 ms |
| コンパイル使用メモリ | 82,184 KB |
| 実行使用メモリ | 599,372 KB |
| 最終ジャッジ日時 | 2025-03-22 15:57:42 |
| 合計ジャッジ時間 | 60,090 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 TLE * 5 MLE * 4 |
ソースコード
mod = 998244353
H, W = map(int, input().split())
S = []
for i in range(H):
s = input()
S.append([s[i] for i in range(W)])
dp = [[[0 for _ in range(H)] for _ in range(W)] for _ in range(H)]
dp[1][0][1] = 1
for h in range(H):
for w in range(W):
for d in range(1, H):
hh, ww = h - d, w + d
if not (0 <= hh < H and 0 <= ww < W):
continue
P, Q = [], []
if h + 1 < H:
if S[h + 1][w] == '.':
P.append((h + 1, w))
if w + 1 < W:
if S[h][w + 1] == '.':
P.append((h, w + 1))
if hh + 1 < H:
if S[hh + 1][ww] == '.':
Q.append((hh + 1, ww))
if ww + 1 < W:
if S[hh][ww + 1] == '.':
Q.append((hh, ww + 1))
for hhh, www in P:
for hhhh, wwww in Q:
if hhh == hhhh and (hhh, www) != (H - 1, W - 1):
continue
dp[hhh][www][hhh - hhhh] = (dp[hhh][www][hhh - hhhh] + dp[h][w][d]) % mod
print(dp[-1][-1][0])
PNJ