結果

問題 No.599 回文かい
ユーザー H3PO4H3PO4
提出日時 2020-10-06 09:04:03
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 751 bytes
コンパイル時間 1,008 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 810,204 KB
最終ジャッジ日時 2023-09-27 06:24:41
合計ジャッジ時間 10,365 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,476 KB
testcase_01 AC 72 ms
71,452 KB
testcase_02 AC 72 ms
71,492 KB
testcase_03 AC 71 ms
71,260 KB
testcase_04 AC 80 ms
76,140 KB
testcase_05 AC 82 ms
76,172 KB
testcase_06 AC 95 ms
76,568 KB
testcase_07 AC 82 ms
76,312 KB
testcase_08 AC 83 ms
76,040 KB
testcase_09 AC 81 ms
76,148 KB
testcase_10 AC 436 ms
77,892 KB
testcase_11 AC 282 ms
77,884 KB
testcase_12 AC 422 ms
80,548 KB
testcase_13 AC 252 ms
78,308 KB
testcase_14 AC 537 ms
77,560 KB
testcase_15 AC 713 ms
81,192 KB
testcase_16 MLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
evil_0.txt -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

rev = lambda x: L - 1 - x

st = set()
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)]:
            st.add((i - j, i + j))
            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)]:
            st.add((i - j, i + j + 1))
            j += 1
        else:
            break

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