結果

問題 No.2528 pop_(backfront or not)
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2023-11-03 21:32:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 612 bytes
コンパイル時間 989 ms
コンパイル使用メモリ 81,876 KB
実行使用メモリ 75,944 KB
最終ジャッジ日時 2023-11-03 21:32:34
合計ジャッジ時間 2,768 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,616 KB
testcase_01 AC 35 ms
53,616 KB
testcase_02 AC 35 ms
53,616 KB
testcase_03 AC 35 ms
53,616 KB
testcase_04 AC 35 ms
53,616 KB
testcase_05 AC 44 ms
62,040 KB
testcase_06 AC 45 ms
62,040 KB
testcase_07 AC 48 ms
62,460 KB
testcase_08 AC 49 ms
64,508 KB
testcase_09 AC 57 ms
68,784 KB
testcase_10 AC 68 ms
72,880 KB
testcase_11 AC 68 ms
73,132 KB
testcase_12 AC 78 ms
75,944 KB
testcase_13 AC 82 ms
75,836 KB
testcase_14 AC 87 ms
75,840 KB
testcase_15 AC 102 ms
75,840 KB
testcase_16 AC 111 ms
75,836 KB
testcase_17 AC 109 ms
75,840 KB
testcase_18 AC 109 ms
75,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

https://yukicoder.me/problems/no/2528



"""

import sys
from sys import stdin

mod = 998244353

N = int(stdin.readline())

dp = [1]

for i in range(N):

    ndp = [0] * (len(dp)+2)

    for j in range(len(dp)):

        # 端で挟む(+1)
        ndp[j+1] += dp[j]

        # 前に2個入れる
        ndp[j+2] += dp[j] * ( j*(j+1)//2 )

        # 後ろに2個入れる
        back = len(dp) - j - 1
        ndp[j] += dp[j] * ( back*(back+1)//2 )

        # 挟む
        ndp[j+1] += dp[j] * j * back

    for j in range(len(ndp)):
        ndp[j] %= mod

    dp = ndp

print (*dp[:2*N+1],sep="\n")


0