結果

問題 No.599 回文かい
ユーザー htkbhtkb
提出日時 2019-02-19 19:28:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 296 bytes
コンパイル時間 400 ms
コンパイル使用メモリ 10,696 KB
実行使用メモリ 21,444 KB
最終ジャッジ日時 2023-08-02 18:49:25
合計ジャッジ時間 11,438 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
21,444 KB
testcase_01 AC 18 ms
7,812 KB
testcase_02 AC 15 ms
7,812 KB
testcase_03 AC 16 ms
7,808 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 TLE -
testcase_15 WA -
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)+1) // 2
s, s_rev = s[:length], s[len(s)//2:]
mod = 10**9+7
dp = [0]*length


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


print(rec(0))
0