結果

問題 No.599 回文かい
ユーザー htkbhtkb
提出日時 2019-02-19 19:50:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 302 bytes
コンパイル時間 127 ms
コンパイル使用メモリ 10,724 KB
実行使用メモリ 13,300 KB
最終ジャッジ日時 2023-08-02 19:27:13
合計ジャッジ時間 11,213 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,784 KB
testcase_01 AC 16 ms
7,784 KB
testcase_02 AC 16 ms
7,824 KB
testcase_03 AC 16 ms
7,828 KB
testcase_04 AC 16 ms
7,828 KB
testcase_05 AC 18 ms
8,124 KB
testcase_06 AC 15 ms
7,836 KB
testcase_07 AC 16 ms
7,824 KB
testcase_08 AC 16 ms
7,860 KB
testcase_09 AC 18 ms
7,908 KB
testcase_10 AC 24 ms
7,852 KB
testcase_11 AC 22 ms
7,832 KB
testcase_12 AC 40 ms
7,940 KB
testcase_13 AC 61 ms
7,784 KB
testcase_14 TLE -
testcase_15 AC 251 ms
8,216 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) // 2
s, s_rev = s[:length], s[(len(s)+1)//2:]
mod = 10**9+7
dp = [0]*(length+1)


def rec(i):
    dp[i] = (sum(dp[j] or rec(j) for j in range(i+1, length+1) if s[i:j] == s_rev[-j:length-i]) + 1) % mod
    return dp[i]


print(rec(0))
0