結果

問題 No.599 回文かい
ユーザー htkbhtkb
提出日時 2019-02-19 19:50:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 302 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2024-04-20 19:33:23
合計ジャッジ時間 2,119 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,496 KB
testcase_01 AC 28 ms
10,496 KB
testcase_02 AC 27 ms
10,624 KB
testcase_03 AC 26 ms
10,496 KB
testcase_04 AC 26 ms
10,496 KB
testcase_05 AC 29 ms
10,752 KB
testcase_06 AC 27 ms
10,624 KB
testcase_07 AC 27 ms
10,496 KB
testcase_08 AC 27 ms
10,624 KB
testcase_09 AC 28 ms
10,496 KB
testcase_10 AC 34 ms
10,496 KB
testcase_11 AC 33 ms
10,496 KB
testcase_12 AC 54 ms
10,496 KB
testcase_13 AC 74 ms
10,624 KB
testcase_14 RE -
testcase_15 AC 262 ms
10,880 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 27 ms
10,624 KB
testcase_19 AC 27 ms
10,496 KB
testcase_20 AC 26 ms
10,496 KB
evil_0.txt RE -
権限があれば一括ダウンロードができます

ソースコード

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