結果

問題 No.1761 Sequence Distance
コンテスト
ユーザー とりゐ
提出日時 2025-12-29 23:17:20
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 6,622 ms / 8,000 ms
+ 862µs
コード長 591 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 241 ms
コンパイル使用メモリ 95,980 KB
実行使用メモリ 305,640 KB
最終ジャッジ日時 2026-07-19 21:51:32
合計ジャッジ時間 70,121 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

mod = 998244353

n, m = map(int, input().split())

K = 31
dp = [[0] * (m + 1) for i in range(K + 1)]
dp[0][0] = 1

for _ in range(n):
    ndp = [[0] * (m + 1) for i in range(K + 1)]
    for d in range(K + 1):
        for s in range(m + 1):
            if d == 0:
                res = [(1, 2), (0, 2)]
            else:
                res = [(d - 1, 1), (d, 2), (d + 1, 1)]
            for nd, w in res:
                ns = s + nd
                if ns <= m and nd <= K:
                    ndp[nd][ns] += dp[d][s] * w
                    ndp[nd][ns] %= mod

    dp = ndp

print(dp[0][m])
0