結果

問題 No.1761 Sequence Distance
ユーザー NyaanNyaanNyaanNyaan
提出日時 2021-10-24 22:47:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 6,565 ms / 8,000 ms
コード長 728 bytes
コンパイル時間 453 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 79,464 KB
最終ジャッジ日時 2023-09-01 23:54:06
合計ジャッジ時間 61,700 ms
ジャッジサーバーID
(参考情報)
judge16 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
71,864 KB
testcase_01 AC 88 ms
71,688 KB
testcase_02 AC 1,671 ms
79,100 KB
testcase_03 AC 87 ms
71,800 KB
testcase_04 AC 88 ms
71,584 KB
testcase_05 AC 87 ms
72,012 KB
testcase_06 AC 129 ms
78,448 KB
testcase_07 AC 115 ms
78,112 KB
testcase_08 AC 129 ms
78,324 KB
testcase_09 AC 114 ms
78,024 KB
testcase_10 AC 133 ms
78,324 KB
testcase_11 AC 140 ms
78,388 KB
testcase_12 AC 117 ms
77,948 KB
testcase_13 AC 125 ms
78,256 KB
testcase_14 AC 119 ms
78,128 KB
testcase_15 AC 129 ms
78,208 KB
testcase_16 AC 129 ms
78,328 KB
testcase_17 AC 112 ms
78,088 KB
testcase_18 AC 137 ms
78,360 KB
testcase_19 AC 121 ms
78,280 KB
testcase_20 AC 124 ms
78,368 KB
testcase_21 AC 1,192 ms
78,560 KB
testcase_22 AC 186 ms
78,436 KB
testcase_23 AC 5,166 ms
79,204 KB
testcase_24 AC 1,627 ms
79,072 KB
testcase_25 AC 4,184 ms
79,464 KB
testcase_26 AC 4,587 ms
79,224 KB
testcase_27 AC 1,491 ms
78,692 KB
testcase_28 AC 1,316 ms
78,768 KB
testcase_29 AC 3,724 ms
79,328 KB
testcase_30 AC 711 ms
78,792 KB
testcase_31 AC 2,066 ms
79,344 KB
testcase_32 AC 222 ms
78,648 KB
testcase_33 AC 2,506 ms
78,932 KB
testcase_34 AC 134 ms
79,160 KB
testcase_35 AC 289 ms
78,236 KB
testcase_36 AC 3,316 ms
78,848 KB
testcase_37 AC 452 ms
78,980 KB
testcase_38 AC 773 ms
78,700 KB
testcase_39 AC 1,880 ms
78,808 KB
testcase_40 AC 643 ms
78,840 KB
testcase_41 AC 5,710 ms
79,088 KB
testcase_42 AC 6,528 ms
79,100 KB
testcase_43 AC 6,565 ms
79,224 KB
testcase_44 AC 91 ms
72,084 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):
      dp[i][j] %= mod

print(dp[0][M])
0