結果
問題 | No.3071 Double Speedrun |
ユーザー |
![]() |
提出日時 | 2025-03-21 23:06:36 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,666 ms / 6,000 ms |
コード長 | 1,636 bytes |
コンパイル時間 | 306 ms |
コンパイル使用メモリ | 82,360 KB |
実行使用メモリ | 263,868 KB |
最終ジャッジ日時 | 2025-03-21 23:07:00 |
合計ジャッジ時間 | 23,001 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
import sys # sys.setrecursionlimit(200005) # sys.set_int_max_str_digits(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = -1-(-1 << 31) inf = -1-(-1 << 62) # md = 10**9+7 md = 998244353 from collections import Counter h, w = LI() ss = [[c == "#" for c in SI()] for _ in range(h)] n = min(h, w) def push(i, j, p, q, val): if i == p or i == h or j == w or p == h or q == w or ss[i][j] or ss[p][q]: return dp[i][p] += val dp[i][p] %= md dp = [[0]*h for _ in range(h)] dp[0][1] = 1 for d in range(1, h+w-3): pre, dp = dp, [[0]*h for _ in range(h)] for p in range(h): q = d-p if q < 0: break if q >= w: continue for i in range(p): j = d-i if j < 0: break if j >= w: continue push(i+1, j, p+1, q, pre[i][p]) push(i+1, j, p, q+1, pre[i][p]) push(i, j+1, p+1, q, pre[i][p]) push(i, j+1, p, q+1, pre[i][p]) # p2D(dp) ans = 0 for p in range(h): for i in range(p): ans += dp[i][p] ans %= md print(ans)