結果

問題 No.3429 Palindromic Path (Hard)
コンテスト
ユーザー hirayuu_yc
提出日時 2025-12-30 00:27:03
言語 PyPy3
(7.3.17)
結果
TLE  
実行時間 -
コード長 504 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 151 ms
コンパイル使用メモリ 82,784 KB
実行使用メモリ 276,660 KB
最終ジャッジ日時 2026-01-11 13:05:44
合計ジャッジ時間 3,952 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 TLE * 1 -- * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from functools import cache
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')
@cache
def dp(x1,y1,x2):
    y2=(N*2-2-x1-y1)-x2
    if c[x1][y1]!=c[x2][y2]:
        return 0
    if x1+y1==x2+y2:
        if (x1,y1)==(x2,y2):
            return 1
        else:
            return 0
    ret=0
    ret+=dp(x1+1,y1,x2-1)
    ret+=dp(x1,y1+1,x2-1)
    ret+=dp(x1+1,y1,x2)
    ret+=dp(x1,y1+1,x2)
    ret%=MOD
    return ret
MOD=998244353
N=int(input())
c=[input() for i in range(N)]
print(dp(0,0,N-1))
0