結果

問題 No.599 回文かい
ユーザー htkb
提出日時 2019-02-08 20:17:03
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 469 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 12,672 KB
最終ジャッジ日時 2024-06-28 16:56:52
合計ジャッジ時間 6,863 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15 TLE * 2 -- * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**6)
S = input()
length = len(S)
mod = 10**9+7
dp = [0]*length


def rec(left_start, right_end):
    count = 1
    for left_end, right_start in zip(range(left_start+1, length//2+1), range(right_end-1, (length+1)//2-1, -1)):
        if S[left_start:left_end] == S[right_start:right_end]:
            count += dp[left_end] or rec(left_end, right_start)

    dp[left_start] = count % mod
    return dp[left_start]


print(rec(0, len(S)))
0