結果

問題 No.465 PPPPPPPPPPPPPPPPAPPPPPPPP
ユーザー りあんりあん
提出日時 2020-11-23 06:28:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,462 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 10,848 KB
実行使用メモリ 114,876 KB
最終ジャッジ日時 2023-09-30 23:37:19
合計ジャッジ時間 8,717 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,632 KB
testcase_01 AC 16 ms
8,168 KB
testcase_02 AC 16 ms
8,208 KB
testcase_03 AC 16 ms
8,164 KB
testcase_04 AC 16 ms
8,148 KB
testcase_05 AC 264 ms
27,828 KB
testcase_06 AC 1,549 ms
110,380 KB
testcase_07 AC 379 ms
28,856 KB
testcase_08 TLE -
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
32_ratsliveonnoevilstar.txt -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools


def pal(s_):
    s = "^" + s_
    n = len(s)
    pl = [[0, 0, 0] for _ in range(n)]
    pl[0][0] = 1
    gpl = [[0, 0, 0] for _ in range(n)]
    g = []
    for j in range(1, n):
        g1 = [(i - 1, d, k) for i, d, k in g if i > 0 and s[i - 1] == s[j]]
        g2 = []
        r = -j
        for i, d, k in g1:
            if i - r != d:
                g2.append((i, i - r, 1))
                if k > 1:
                    g2.append((i + d, d, k - 1))
            else:
                g2.append((i, d, k))
            r = i + (k - 1) * d
        if j > 1 and s[j - 1] == s[j]:
            g2.append((j - 1, j - 1 - r, 1))
            r = j - 1
        g2.append((j, j - r, 1))
        g = []
        for i, d, k in g2:
            if not g or g[-1][1] != d:
                g.append((i, d, k))
            else:
                g[-1] = (g[-1][0], g[-1][1], g[-1][2] + k)
        # pl[j] = 0
        for i, d, k in g:
            r = i + (k - 1) * d
            m = [0, pl[r - 1][0], pl[r - 1][1]]
            if k > 1:
                for l in range(3):
                    m[l] += gpl[i - d][l]
            if d <= i:
                gpl[i - d] = m
            for l in range(3):
                pl[j][l] += m[l]
    return (pl, g)


pl, g = pal(input())
accum = list(itertools.accumulate([i[-1] for i in pl]))
ans = 0
for i, d, k in g:
    for j in range(k):
        if i + d * j > 1:
            ans += accum[i + d * j - 2]

print(ans)
0