結果

問題 No.1761 Sequence Distance
ユーザー NyaanNyaanNyaanNyaan
提出日時 2021-10-24 22:53:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 5,382 ms / 8,000 ms
コード長 695 bytes
コンパイル時間 402 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 78,488 KB
最終ジャッジ日時 2023-09-01 23:52:50
合計ジャッジ時間 51,599 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,768 KB
testcase_01 AC 73 ms
71,440 KB
testcase_02 AC 1,379 ms
78,080 KB
testcase_03 AC 72 ms
71,388 KB
testcase_04 AC 72 ms
71,520 KB
testcase_05 AC 73 ms
71,312 KB
testcase_06 AC 116 ms
78,004 KB
testcase_07 AC 92 ms
77,000 KB
testcase_08 AC 115 ms
77,952 KB
testcase_09 AC 100 ms
77,600 KB
testcase_10 AC 115 ms
77,604 KB
testcase_11 AC 119 ms
77,864 KB
testcase_12 AC 101 ms
77,144 KB
testcase_13 AC 109 ms
77,888 KB
testcase_14 AC 98 ms
77,432 KB
testcase_15 AC 116 ms
77,728 KB
testcase_16 AC 114 ms
77,624 KB
testcase_17 AC 91 ms
76,756 KB
testcase_18 AC 121 ms
77,744 KB
testcase_19 AC 105 ms
77,496 KB
testcase_20 AC 111 ms
77,780 KB
testcase_21 AC 993 ms
77,560 KB
testcase_22 AC 164 ms
77,912 KB
testcase_23 AC 4,277 ms
78,168 KB
testcase_24 AC 1,349 ms
78,260 KB
testcase_25 AC 3,506 ms
78,208 KB
testcase_26 AC 3,799 ms
78,004 KB
testcase_27 AC 1,235 ms
77,912 KB
testcase_28 AC 1,098 ms
78,004 KB
testcase_29 AC 3,100 ms
78,156 KB
testcase_30 AC 602 ms
77,452 KB
testcase_31 AC 1,701 ms
77,792 KB
testcase_32 AC 193 ms
77,864 KB
testcase_33 AC 2,072 ms
77,824 KB
testcase_34 AC 112 ms
77,604 KB
testcase_35 AC 251 ms
77,452 KB
testcase_36 AC 2,759 ms
77,968 KB
testcase_37 AC 383 ms
77,800 KB
testcase_38 AC 644 ms
77,760 KB
testcase_39 AC 1,551 ms
77,552 KB
testcase_40 AC 538 ms
77,996 KB
testcase_41 AC 4,729 ms
78,268 KB
testcase_42 AC 5,382 ms
78,488 KB
testcase_43 AC 5,374 ms
78,248 KB
testcase_44 AC 75 ms
71,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt

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

dp = [[0] * (M + 1) for _ in range(sq)]
nx = [[0] * (M + 1) for _ in range(sq)]
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