結果

問題 No.2204 Palindrome Splitting (No Rearrangement ver.)
ユーザー HydruHydru
提出日時 2023-02-03 22:12:18
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 623 bytes
コンパイル時間 545 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 83,736 KB
最終ジャッジ日時 2023-09-15 18:09:26
合計ジャッジ時間 27,036 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
75,640 KB
testcase_01 AC 73 ms
71,280 KB
testcase_02 AC 70 ms
71,432 KB
testcase_03 AC 540 ms
77,544 KB
testcase_04 AC 205 ms
77,552 KB
testcase_05 AC 153 ms
77,672 KB
testcase_06 AC 828 ms
77,336 KB
testcase_07 AC 701 ms
77,616 KB
testcase_08 AC 705 ms
77,432 KB
testcase_09 AC 1,570 ms
78,708 KB
testcase_10 AC 819 ms
77,636 KB
testcase_11 AC 686 ms
77,456 KB
testcase_12 AC 767 ms
77,732 KB
testcase_13 AC 796 ms
77,552 KB
testcase_14 AC 764 ms
77,524 KB
testcase_15 AC 880 ms
78,124 KB
testcase_16 AC 373 ms
77,432 KB
testcase_17 AC 427 ms
77,448 KB
testcase_18 AC 782 ms
77,708 KB
testcase_19 AC 843 ms
77,644 KB
testcase_20 AC 762 ms
77,484 KB
testcase_21 AC 855 ms
77,640 KB
testcase_22 AC 749 ms
77,532 KB
testcase_23 AC 809 ms
77,904 KB
testcase_24 TLE -
testcase_25 AC 849 ms
78,120 KB
testcase_26 AC 834 ms
77,500 KB
testcase_27 AC 1,381 ms
78,480 KB
testcase_28 AC 793 ms
77,668 KB
testcase_29 AC 770 ms
77,508 KB
testcase_30 AC 71 ms
71,276 KB
testcase_31 AC 69 ms
71,392 KB
testcase_32 TLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()

n=len(S)

DP=[1 for _ in range(n+1)]

DP[0]=len(S)
s_to_n={chr(i+97):i for i in range(26)}

def is_kaibun(s):
    n=len(s)
    for i in range(n//2):
        if s[i]!=s[n-1-i]:
            return 0
    return 1

for i in range(n):
    cnt=1<<s_to_n[S[i]]
    for j in range(i+1,n):
        s=S[j]
        cnt^=1<<s_to_n[s]
        if (j+i)%2==0 and cnt^(1<<s_to_n[S[(i+j)//2]])==0:
            if is_kaibun(S[i:j+1]):
                DP[j+1]=max(min(DP[i],j-i+1),DP[j+1])
        elif (j+i)%2==1 and cnt==0:
            if is_kaibun(S[i:j+1]):
                DP[j+1]=max(min(DP[i],j-i+1),DP[j+1])

print(DP[-1])
0