結果
問題 |
No.3071 Double Speedrun
|
ユーザー |
![]() |
提出日時 | 2025-03-22 16:03:45 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 5,330 ms / 6,000 ms |
コード長 | 1,119 bytes |
コンパイル時間 | 373 ms |
コンパイル使用メモリ | 82,320 KB |
実行使用メモリ | 266,028 KB |
最終ジャッジ日時 | 2025-03-22 16:04:36 |
合計ジャッジ時間 | 48,629 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
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(H)] dp[1][1] = 1 for t in range(1, H + W - 2): ndp = [[0 for _ in range(H)] for _ in range(H)] for h in range(1, H): w = t - h if not (0 <= w < W): continue 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 ndp[hhh][hhh - hhhh] = (ndp[hhh][hhh - hhhh] + dp[h][d]) % mod for h in range(H): for hh in range(H): dp[h][hh] = ndp[h][hh] print(dp[H - 1][0])