結果

問題 No.2204 Palindrome Splitting (No Rearrangement ver.)
ユーザー ntudantuda
提出日時 2023-02-06 22:28:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 858 ms / 2,000 ms
コード長 837 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 309,556 KB
最終ジャッジ日時 2023-09-18 08:18:37
合計ジャッジ時間 7,213 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,376 KB
testcase_01 AC 71 ms
71,436 KB
testcase_02 AC 69 ms
71,644 KB
testcase_03 AC 117 ms
77,884 KB
testcase_04 AC 102 ms
77,400 KB
testcase_05 AC 102 ms
78,012 KB
testcase_06 AC 111 ms
77,992 KB
testcase_07 AC 112 ms
78,004 KB
testcase_08 AC 113 ms
77,968 KB
testcase_09 AC 122 ms
77,896 KB
testcase_10 AC 121 ms
78,024 KB
testcase_11 AC 118 ms
77,884 KB
testcase_12 AC 116 ms
77,980 KB
testcase_13 AC 113 ms
78,132 KB
testcase_14 AC 121 ms
77,892 KB
testcase_15 AC 128 ms
78,144 KB
testcase_16 AC 109 ms
77,592 KB
testcase_17 AC 113 ms
77,980 KB
testcase_18 AC 118 ms
77,988 KB
testcase_19 AC 123 ms
78,076 KB
testcase_20 AC 120 ms
78,060 KB
testcase_21 AC 113 ms
78,096 KB
testcase_22 AC 117 ms
78,060 KB
testcase_23 AC 117 ms
78,052 KB
testcase_24 AC 125 ms
78,092 KB
testcase_25 AC 124 ms
77,912 KB
testcase_26 AC 122 ms
78,068 KB
testcase_27 AC 131 ms
78,084 KB
testcase_28 AC 121 ms
78,000 KB
testcase_29 AC 113 ms
78,212 KB
testcase_30 AC 71 ms
71,496 KB
testcase_31 AC 77 ms
71,372 KB
testcase_32 AC 858 ms
308,980 KB
testcase_33 AC 120 ms
77,956 KB
testcase_34 AC 70 ms
71,128 KB
testcase_35 AC 825 ms
309,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
N = len(S)
T = S[::-1]
E = [[] for _ in range(N)]

def search(l, r):
    n2 = (r - l) // 2
    l0 = l + n2
    r0 = r - n2

    lb = 0
    ub = n2 + 1

    while ub - lb > 1:
        mid = (ub + lb) // 2
        if S[l0 - mid:r0 + mid] == T[N - r0 - mid:N - l0 + mid]:
            lb = mid
        else:
            ub = mid
    return lb

l = 0
for r in range(1, N + 1):
    x = (r - l) // 2 - search(l, r)
    l2 = l + x;
    r2 = r - x
    while r2 - l2 > 0:
        E[l2].append(r2)
        l2 += 1;
        r2 -= 1

r = N
for l in range(1, N):
    x = (r - l) // 2 - search(l, r)
    l2 = l + x;
    r2 = r - x
    while r2 - l2 > 0:
        E[l2].append(r2)
        l2 += 1;
        r2 -= 1

dp = [0] * (N + 1)
dp[0] = N
for i in range(N):
    for j in E[i]:
        dp[j] = max(dp[j], min(dp[i], j - i))

print(dp[N])
0