結果
| 問題 | No.3429 Palindromic Path (Hard) |
| コンテスト | |
| ユーザー |
回転
|
| 提出日時 | 2026-01-11 17:34:23 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 619 bytes |
| 記録 | |
| コンパイル時間 | 437 ms |
| コンパイル使用メモリ | 82,576 KB |
| 実行使用メモリ | 416,364 KB |
| 最終ジャッジ日時 | 2026-01-11 17:34:28 |
| 合計ジャッジ時間 | 4,563 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 3 TLE * 1 -- * 3 |
ソースコード
from functools import cache
MOD = 998244353
N = int(input())
C = [input() for _ in range(N)]
@cache
def f(y,x,yy,xx):
if(y + x == N-1):return y == yy
ret = 0
if(C[y+1][x] == C[yy-1][xx]):
ret += f(y+1,x,yy-1,xx)
ret %= MOD
if(C[y+1][x] == C[yy][xx-1]):
ret += f(y+1,x,yy,xx-1)
ret %= MOD
if(C[y][x+1] == C[yy-1][xx]):
ret += f(y,x+1,yy-1,x)
ret %= MOD
if(C[y][x+1] == C[yy][xx-1]):
ret += f(y,x+1,yy,xx-1)
ret %= MOD
return ret
if(C[0][0] == C[N-1][N-1]):
print(f(0,0,N-1,N-1))
else:
print(0)
回転