結果
| 問題 |
No.765 ukuku 2
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 21:44:35 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 865 bytes |
| コンパイル時間 | 197 ms |
| コンパイル使用メモリ | 82,496 KB |
| 実行使用メモリ | 71,112 KB |
| 最終ジャッジ日時 | 2025-06-12 21:49:18 |
| 合計ジャッジ時間 | 7,390 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 28 TLE * 1 -- * 19 |
ソースコード
def manachers(s):
n = len(s)
if n == 0:
return 0
s = '#' + '#'.join(s) + '#'
n = len(s)
p = [0] * n
C, R = 0, 0
max_len = 0
for i in range(n):
mirror = 2 * C - i
if i < R:
p[i] = min(R - i, p[mirror])
a, b = i + (1 + p[i]), i - (1 + p[i])
while a < n and b >= 0 and s[a] == s[b]:
p[i] += 1
a += 1
b -= 1
if i + p[i] > R:
C = i
R = i + p[i]
max_len = max(max_len, p[i])
return max_len
def main():
import sys
input = sys.stdin.read
s = input().strip()
max_len = 0
n = len(s)
for i in range(n):
new_s = s[:i] + s[i+1:]
current = manachers(new_s)
if current > max_len:
max_len = current
print(max_len)
if __name__ == "__main__":
main()
gew1fw