結果

問題 No.1761 Sequence Distance
コンテスト
ユーザー NyaanNyaan
提出日時 2021-10-24 22:43:45
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
(最新)
MLE  
(最初)
実行時間 -
コード長 678 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 346 ms
コンパイル使用メモリ 84,992 KB
実行使用メモリ 309,632 KB
最終ジャッジ日時 2026-06-06 15:38:52
合計ジャッジ時間 17,624 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 TLE * 1 -- * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from math import sqrt
from copy import deepcopy

mod = 998244353
N, M = map(int, input().split())
sq = int(sqrt(2 * M) + 3)

init = [[0] * (M + 1) for _ in range(sq)]
dp = deepcopy(init)
dp[0][0] = 1

for _ in range(N):
  nx = deepcopy(init)
  for i in range(sq):
    for j in range(M + 1):
      if dp[i][j] == 0:
        continue
      im1 = abs(i - 1)
      if j + im1 <= M:
        nx[im1][j + im1] += dp[i][j]
        nx[im1][j + im1] %= mod
      if j + i <= M:
        nx[i][j + i] += dp[i][j] * 2
        nx[i][j + i] %= mod
      if i != sq - 1 and j + i + 1 <= M:
        nx[i + 1][j + i + 1] += dp[i][j]
        nx[i + 1][j + i + 1] %= mod
  dp = nx

print(dp[0][M])
0