結果

問題 No.599 回文かい
コンテスト
ユーザー sibasyun
提出日時 2023-12-15 11:26:04
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 847 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 590 ms
コンパイル使用メモリ 20,576 KB
実行使用メモリ 683,612 KB
最終ジャッジ日時 2026-04-14 02:09:43
合計ジャッジ時間 13,921 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9 WA * 2 MLE * 4 -- * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import io
import sys
import bisect
import math
from itertools import permutations, combinations
from heapq import heappush, heappop
from collections import deque
from collections import defaultdict as dd
sys.setrecursionlimit(10**7+10)

mod = 998244353

_INPUT = """\
kaibunkaibunkai


"""



def main():
    T = input()
    N = len(T)
    dp = [[-1 for _ in range(N+1)]for _ in range(N+1)] # 区間l,rのときのケース数
    def dfs(l, r):
        if dp[l][r] != -1:
            return dp[l][r]
        else:
            ret = 1
            for i in range(r-l):
                if l+i>=r-1-i:break
                if T[l:l+i+1] == T[r-1-i:r]:
                    ret += dfs(l+i+1, r-1-i)
        dp[l][r] = ret
        return ret
    dfs(0, N)
    print(dp[0][N])

if __name__ == "__main__":
    # sys.stdin = io.StringIO(_INPUT)
    main()
0