結果

問題 No.3213 depth max K
ユーザー titia
提出日時 2025-07-25 22:35:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 900 ms / 2,000 ms
コード長 599 bytes
コンパイル時間 399 ms
コンパイル使用メモリ 82,208 KB
実行使用メモリ 78,936 KB
最終ジャッジ日時 2025-07-25 22:36:07
合計ジャッジ時間 10,930 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,K=map(int,input().split())

mod=998244353

DP0=[0]*(K+1)
DP1=[0]*(K+1)

DP0[0]=1

for i in range(2*N):
    #print(DP0,DP1)
    NDP0=[0]*(K+1)
    NDP1=[0]*(K+1)

    for j in range(K+1):
        if j+1<K:
            NDP0[j+1]=(NDP0[j+1]+DP0[j])%mod
        elif j+1==K:
            NDP1[K]=(NDP1[K]+DP0[j])%mod

        if j-1>=0:
            NDP0[j-1]=(NDP0[j-1]+DP0[j])%mod


        if j+1<=K:
            NDP1[j+1]=(NDP1[j+1]+DP1[j])%mod
        if j-1>=0:
            NDP1[j-1]=(NDP1[j-1]+DP1[j])%mod

    DP0=NDP0
    DP1=NDP1

print(DP1[0]%mod)
    
0