結果

問題 No.1761 Sequence Distance
ユーザー NyaanNyaanNyaanNyaan
提出日時 2021-10-24 22:49:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 7,453 ms / 8,000 ms
コード長 749 bytes
コンパイル時間 472 ms
コンパイル使用メモリ 87,252 KB
実行使用メモリ 79,444 KB
最終ジャッジ日時 2023-09-01 23:51:49
合計ジャッジ時間 69,423 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
71,788 KB
testcase_01 AC 85 ms
71,712 KB
testcase_02 AC 1,886 ms
79,444 KB
testcase_03 AC 90 ms
71,552 KB
testcase_04 AC 89 ms
71,908 KB
testcase_05 AC 89 ms
71,696 KB
testcase_06 AC 136 ms
78,252 KB
testcase_07 AC 119 ms
77,864 KB
testcase_08 AC 136 ms
78,364 KB
testcase_09 AC 116 ms
77,896 KB
testcase_10 AC 135 ms
78,340 KB
testcase_11 AC 144 ms
78,500 KB
testcase_12 AC 120 ms
77,868 KB
testcase_13 AC 130 ms
78,440 KB
testcase_14 AC 124 ms
78,360 KB
testcase_15 AC 134 ms
78,340 KB
testcase_16 AC 133 ms
78,412 KB
testcase_17 AC 116 ms
78,172 KB
testcase_18 AC 141 ms
78,404 KB
testcase_19 AC 127 ms
78,460 KB
testcase_20 AC 130 ms
78,020 KB
testcase_21 AC 1,342 ms
78,928 KB
testcase_22 AC 200 ms
79,124 KB
testcase_23 AC 5,889 ms
79,324 KB
testcase_24 AC 1,825 ms
79,344 KB
testcase_25 AC 4,866 ms
78,876 KB
testcase_26 AC 5,216 ms
79,428 KB
testcase_27 AC 1,672 ms
78,804 KB
testcase_28 AC 1,487 ms
78,608 KB
testcase_29 AC 4,237 ms
79,320 KB
testcase_30 AC 808 ms
78,808 KB
testcase_31 AC 2,342 ms
79,364 KB
testcase_32 AC 239 ms
78,856 KB
testcase_33 AC 2,828 ms
78,800 KB
testcase_34 AC 137 ms
79,060 KB
testcase_35 AC 316 ms
78,392 KB
testcase_36 AC 3,782 ms
78,880 KB
testcase_37 AC 498 ms
78,896 KB
testcase_38 AC 865 ms
78,764 KB
testcase_39 AC 2,129 ms
78,872 KB
testcase_40 AC 712 ms
78,908 KB
testcase_41 AC 6,509 ms
79,156 KB
testcase_42 AC 7,447 ms
79,300 KB
testcase_43 AC 7,453 ms
79,104 KB
testcase_44 AC 87 ms
71,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
nx = deepcopy(init)
dp[0][0] = 1

for _ in range(N):
  for i in range(sq):
    for j in range(M + 1):
      nx[i][j] = 0
  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]
      if j + i <= M:
        nx[i][j + i] += dp[i][j] * 2
      if i != sq - 1 and j + i + 1 <= M:
        nx[i + 1][j + i + 1] += dp[i][j]
  dp, nx = nx, dp

  for i in range(sq):
    for j in range(M + 1):
      if dp[i][j]:
        dp[i][j] %= mod

print(dp[0][M])
0