結果

問題 No.1761 Sequence Distance
ユーザー NyaanNyaanNyaanNyaan
提出日時 2021-10-24 22:56:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 6,674 ms / 8,000 ms
コード長 673 bytes
コンパイル時間 986 ms
コンパイル使用メモリ 87,292 KB
実行使用メモリ 78,472 KB
最終ジャッジ日時 2023-09-01 23:56:51
合計ジャッジ時間 66,628 ms
ジャッジサーバーID
(参考情報)
judge16 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,492 KB
testcase_01 AC 81 ms
76,828 KB
testcase_02 AC 1,690 ms
78,472 KB
testcase_03 AC 82 ms
76,640 KB
testcase_04 AC 80 ms
76,824 KB
testcase_05 AC 86 ms
76,784 KB
testcase_06 AC 119 ms
77,656 KB
testcase_07 AC 110 ms
77,564 KB
testcase_08 AC 123 ms
77,352 KB
testcase_09 AC 97 ms
76,920 KB
testcase_10 AC 121 ms
77,344 KB
testcase_11 AC 130 ms
77,536 KB
testcase_12 AC 113 ms
77,220 KB
testcase_13 AC 113 ms
77,496 KB
testcase_14 AC 109 ms
77,416 KB
testcase_15 AC 123 ms
77,864 KB
testcase_16 AC 123 ms
77,412 KB
testcase_17 AC 106 ms
77,508 KB
testcase_18 AC 128 ms
77,480 KB
testcase_19 AC 114 ms
77,616 KB
testcase_20 AC 112 ms
77,348 KB
testcase_21 AC 1,552 ms
77,820 KB
testcase_22 AC 207 ms
77,864 KB
testcase_23 AC 5,475 ms
78,432 KB
testcase_24 AC 1,690 ms
78,028 KB
testcase_25 AC 4,595 ms
77,764 KB
testcase_26 AC 4,761 ms
78,208 KB
testcase_27 AC 1,947 ms
77,688 KB
testcase_28 AC 1,470 ms
77,936 KB
testcase_29 AC 3,887 ms
78,172 KB
testcase_30 AC 956 ms
77,924 KB
testcase_31 AC 2,191 ms
78,388 KB
testcase_32 AC 263 ms
77,960 KB
testcase_33 AC 2,979 ms
77,996 KB
testcase_34 AC 119 ms
77,324 KB
testcase_35 AC 426 ms
77,696 KB
testcase_36 AC 3,659 ms
78,200 KB
testcase_37 AC 577 ms
77,940 KB
testcase_38 AC 919 ms
77,880 KB
testcase_39 AC 2,169 ms
77,772 KB
testcase_40 AC 906 ms
77,676 KB
testcase_41 AC 5,940 ms
78,196 KB
testcase_42 AC 6,656 ms
78,228 KB
testcase_43 AC 6,674 ms
78,372 KB
testcase_44 AC 74 ms
71,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt

mod = 998244353
N, M = map(int, input().split())

dp = [[0] * (M + 1) for _ in range(50)]
nx = [[0] * (M + 1) for _ in range(50)]
dp[0][0] = 1

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

print(dp[0][M])
0