結果

問題 No.2528 pop_(backfront or not)
ユーザー titiatitia
提出日時 2023-11-03 22:34:04
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 996 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 81,848 KB
実行使用メモリ 449,288 KB
最終ジャッジ日時 2023-11-03 22:34:20
合計ジャッジ時間 15,372 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 212 ms
251,996 KB
testcase_01 AC 216 ms
251,844 KB
testcase_02 AC 209 ms
251,844 KB
testcase_03 AC 232 ms
251,844 KB
testcase_04 AC 210 ms
251,844 KB
testcase_05 AC 262 ms
274,732 KB
testcase_06 AC 270 ms
275,284 KB
testcase_07 AC 315 ms
276,044 KB
testcase_08 AC 371 ms
278,520 KB
testcase_09 AC 632 ms
293,328 KB
testcase_10 AC 1,666 ms
336,048 KB
testcase_11 AC 1,726 ms
346,444 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

mod=998244353

FACT=[1]
for i in range(1,2*10**5+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(2*10**5,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]%mod*FACT_INV[a-b]%mod
    else:
        return 0

N=int(input())

LIST=[[-1]*5000 for i in range(5000)]
def calc(x,y):
    if y==1 or y==x:
        return 0
    if x==3:
        if y==2:
            return 1
        else:
            return 0

    if LIST[x][y]!=-1:
        return LIST[x][y]

    ANS=0

    # 左から二つ
    ANS+=Combi(y-1-1,2)*calc(x-2,y-2)
    # 左右一つずつ
    ANS+=Combi(y-1-1,1)*Combi(x-y-1,1)*calc(x-2,y-1)
    # 端二つ
    ANS+=calc(x-2,y-1)
    # 右から二つ
    ANS+=Combi(x-y-1,2)*calc(x-2,y)

    LIST[x][y]=ANS%mod

    return LIST[x][y]

for i in range(1,N*2+2):
    print(calc(N*2+1,i))
    

    
0