結果

問題 No.464 PPAP
ユーザー H3PO4H3PO4
提出日時 2020-09-07 12:44:42
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 467 bytes
コンパイル時間 1,111 ms
コンパイル使用メモリ 86,708 KB
実行使用メモリ 77,312 KB
最終ジャッジ日時 2023-08-19 16:34:11
合計ジャッジ時間 14,409 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,064 KB
testcase_01 AC 70 ms
71,060 KB
testcase_02 AC 70 ms
71,200 KB
testcase_03 AC 70 ms
71,020 KB
testcase_04 AC 89 ms
76,200 KB
testcase_05 AC 89 ms
76,672 KB
testcase_06 AC 83 ms
76,692 KB
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def is_palindrome(s):
    return s == s[::-1]


S = input()

L = len(S)
P, PP, PPA, PPAP = ([0] * L for _ in range(4))
for i in range(L):
    # PPAP
    for j in range(i + 1):
        if is_palindrome(S[j:i + 1]):
            PPAP[i] += PPA[j - 1]

    # PPA
    PPA[i] += sum(PP[:i])

    # PP
    for j in range(i + 1):
        if is_palindrome(S[j:i + 1]):
            PP[i] += P[j - 1]

    # P
    if is_palindrome(S[:i + 1]):
        P[i] += 1

print(PPAP[-1])
0