結果

問題 No.599 回文かい
ユーザー H3PO4H3PO4
提出日時 2020-10-06 08:51:37
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 801 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 277,904 KB
最終ジャッジ日時 2023-09-27 06:23:26
合計ジャッジ時間 9,693 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,424 KB
testcase_01 AC 62 ms
71,284 KB
testcase_02 AC 65 ms
71,420 KB
testcase_03 AC 66 ms
71,348 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 MLE -
testcase_16 RE -
testcase_17 MLE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
evil_0.txt RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
L = len(S)
MOD = 1_000_000_007

rev = lambda x: L - 1 - x

table = [[False] * (L // 2) for _ in range(L // 2)]
for i in range(L // 2):
    # 奇数長
    j = 0
    while i - j >= 0 and i + j < L // 2:
        if S[i - j] == S[rev(i + j)] and S[i + j] == S[rev(i - j)]:
            table[i - j][i + j] = True
            j += 1
        else:
            break

    # 偶数長
    j = 0
    while i - j >= 0 and i + j + 1 < L // 2:
        if S[i - j] == S[rev(i + j + 1)] and S[i + j + 1] == S[rev(i - j)]:
            table[i - j][i + j + 1] = True
            j += 1
        else:
            break

dp = [0] * ((L + 1) // 2)
dp[0] = 1
for i in range(L // 2):
    for j in range(i, L // 2):
        if table[i][j]:
            dp[j + 1] = (dp[j + 1] + dp[i]) % MOD
print(sum(dp) % MOD)
0