結果

問題 No.2528 pop_(backfront or not)
ユーザー lloyzlloyz
提出日時 2023-11-12 18:45:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,923 ms / 2,000 ms
コード長 556 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 201,716 KB
最終ジャッジ日時 2023-11-12 18:45:43
合計ジャッジ時間 13,184 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 33 ms
53,460 KB
testcase_03 AC 34 ms
53,460 KB
testcase_04 AC 36 ms
53,460 KB
testcase_05 AC 59 ms
70,268 KB
testcase_06 AC 68 ms
73,340 KB
testcase_07 AC 89 ms
77,296 KB
testcase_08 AC 108 ms
78,468 KB
testcase_09 AC 226 ms
85,676 KB
testcase_10 AC 528 ms
106,868 KB
testcase_11 AC 585 ms
109,556 KB
testcase_12 AC 774 ms
124,276 KB
testcase_13 AC 869 ms
129,268 KB
testcase_14 AC 1,047 ms
141,556 KB
testcase_15 AC 1,572 ms
178,292 KB
testcase_16 AC 1,923 ms
201,460 KB
testcase_17 AC 1,898 ms
201,716 KB
testcase_18 AC 1,918 ms
201,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
mod = 998244353

inv2 = pow(2, mod - 2, mod)
DP = [[0 for _ in range(2 * n + 1)] for _ in range(2 * n + 1)]
DP[0][0] = 1
for i in range(2 * n + 1):
    for j in range(2 * n + 1):
        if i >= 1 and j >= 1:
            DP[i][j] += DP[i - 1][j - 1] * ((i - 1) * (j - 1) + 1) % mod
        if i >= 2:
            DP[i][j] += DP[i - 2][j] * (i - 1) * (i - 2) * inv2 % mod
        if j >= 2:
            DP[i][j] += DP[i][j - 2] * (j - 1) * (j - 2) * inv2 % mod
        DP[i][j] %= mod
for i in range(2 * n + 1):
    print(DP[i][2 * n - i])
0