結果

問題 No.2528 pop_(backfront or not)
コンテスト
ユーザー ntuda
提出日時 2026-01-16 13:47:44
言語 PyPy3
(7.3.17)
結果
AC  
実行時間 1,635 ms / 2,000 ms
コード長 780 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 436 ms
コンパイル使用メモリ 82,392 KB
実行使用メモリ 298,808 KB
最終ジャッジ日時 2026-01-16 13:47:56
合計ジャッジ時間 11,659 ms
ジャッジサーバーID
(参考情報)
judge6 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys

sys.setrecursionlimit(10050)

from collections import defaultdict

dic = defaultdict(int)
MOD = 998244353
N = int(input())
N2 = 2 * N + 1


def code(x, y):
    if x > y:
        x, y = y, x
    return x * N2 + y


def f(lr):
    if lr in dic:
        return dic[lr]
    l = lr // N2
    r = lr % N2
    ret = 0
    if l > 1 and r > 1:
        ret += ((l - 1) * (r - 1) + 1) * f(code(l - 1, r - 1))
    if r > 2:
        ret += (r - 1) * (r - 2) // 2 * f(code(l, r - 2))
    if l > 2:
        ret += (l - 1) * (l - 2) // 2 * f(code(l - 2, r))
    if l == 1 and r == 1:
        ret += 1
    dic[lr] = ret % MOD
    return ret % MOD


ans = [0] * (2 * N + 1)
for i in range(N + 1):
    a = f(code(i, 2 * N - i))
    ans[i] = ans[2 * N - i] = a
for a in ans:
    print(a)
0