結果

問題 No.2204 Palindrome Splitting (No Rearrangement ver.)
ユーザー flygonflygon
提出日時 2023-02-03 22:11:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 838 bytes
コンパイル時間 357 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 707,104 KB
最終ジャッジ日時 2023-09-15 18:07:01
合計ジャッジ時間 8,587 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 93 ms
71,608 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 126 ms
78,788 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 128 ms
78,512 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 87 ms
71,692 KB
testcase_31 WA -
testcase_32 MLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

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())
n = len(s)
pal = set()
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]:
      pal.add((ll,rr))
    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]:
      pal.add((ll,rr))
    else:
      break
dr = defaultdict(list)
for l,r in pal:
  dr[r].append(l)
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