結果

問題 No.2204 Palindrome Splitting (No Rearrangement ver.)
ユーザー flygonflygon
提出日時 2023-02-03 22:20:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 864 ms / 2,000 ms
コード長 809 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 86,724 KB
実行使用メモリ 321,860 KB
最終ジャッジ日時 2023-09-15 18:22:49
合計ジャッジ時間 7,581 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
71,324 KB
testcase_01 AC 99 ms
71,540 KB
testcase_02 AC 97 ms
71,800 KB
testcase_03 AC 124 ms
78,216 KB
testcase_04 AC 114 ms
78,088 KB
testcase_05 AC 120 ms
77,372 KB
testcase_06 AC 124 ms
78,084 KB
testcase_07 AC 122 ms
78,092 KB
testcase_08 AC 122 ms
77,880 KB
testcase_09 AC 131 ms
78,360 KB
testcase_10 AC 127 ms
78,164 KB
testcase_11 AC 120 ms
77,932 KB
testcase_12 AC 122 ms
77,856 KB
testcase_13 AC 120 ms
78,000 KB
testcase_14 AC 121 ms
78,128 KB
testcase_15 AC 129 ms
78,096 KB
testcase_16 AC 127 ms
78,056 KB
testcase_17 AC 122 ms
77,560 KB
testcase_18 AC 126 ms
78,404 KB
testcase_19 AC 123 ms
78,016 KB
testcase_20 AC 126 ms
78,696 KB
testcase_21 AC 124 ms
77,548 KB
testcase_22 AC 129 ms
77,976 KB
testcase_23 AC 126 ms
77,992 KB
testcase_24 AC 137 ms
78,396 KB
testcase_25 AC 124 ms
78,180 KB
testcase_26 AC 129 ms
78,512 KB
testcase_27 AC 128 ms
78,164 KB
testcase_28 AC 133 ms
78,000 KB
testcase_29 AC 125 ms
77,804 KB
testcase_30 AC 97 ms
71,456 KB
testcase_31 AC 94 ms
71,472 KB
testcase_32 AC 864 ms
321,636 KB
testcase_33 AC 121 ms
78,112 KB
testcase_34 AC 94 ms
71,708 KB
testcase_35 AC 815 ms
321,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd
s = list(input().rstrip())
n = len(s)
dr = [[] for i in range(n)]
for i in range(n):
  l, r= i,i
  for j in range(n):
    ll = l-j
    rr = r+j
    if ll < 0 or rr >= n: break
    if s[ll] == s[rr]:
      dr[rr].append(ll)
    else:
      break

for i in range(n-1):
  l, r = i, i+1
  for j in range(n):
    ll = l-j
    rr = r+j
    if ll < 0 or rr >= n: break
    if s[ll] == s[rr]:
      dr[rr].append(ll)
    else:
      break

dp = [1]*(n)
for i in range(1, n):
  for j in dr[i]:
    if j == 0:
      dp[i] = i+1
    else:
      dp[i] = max(dp[i],min(i-j+1, dp[j-1]))
print(dp[-1])
0