結果

問題 No.599 回文かい
ユーザー htkbhtkb
提出日時 2019-02-08 20:17:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 469 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 10,600 KB
実行使用メモリ 14,848 KB
最終ジャッジ日時 2023-09-11 02:27:03
合計ジャッジ時間 11,024 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
12,148 KB
testcase_01 AC 16 ms
7,828 KB
testcase_02 AC 16 ms
7,828 KB
testcase_03 AC 16 ms
7,828 KB
testcase_04 AC 17 ms
7,688 KB
testcase_05 AC 19 ms
7,988 KB
testcase_06 AC 16 ms
7,664 KB
testcase_07 AC 16 ms
7,724 KB
testcase_08 AC 16 ms
7,840 KB
testcase_09 AC 17 ms
7,712 KB
testcase_10 AC 24 ms
7,696 KB
testcase_11 AC 23 ms
8,028 KB
testcase_12 AC 42 ms
7,776 KB
testcase_13 AC 60 ms
7,716 KB
testcase_14 TLE -
testcase_15 AC 247 ms
8,064 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
evil_0.txt -- -
権限があれば一括ダウンロードができます

ソースコード

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