結果
問題 |
No.765 ukuku 2
|
ユーザー |
![]() |
提出日時 | 2025-05-14 12:52:32 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 647 bytes |
コンパイル時間 | 275 ms |
コンパイル使用メモリ | 82,708 KB |
実行使用メモリ | 81,808 KB |
最終ジャッジ日時 | 2025-05-14 12:54:29 |
合計ジャッジ時間 | 4,600 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 19 WA * 29 |
ソースコード
S = input().strip() def longest_palindrome(s): if not s: return 0 t = '#' + '#'.join(s) + '#' n = len(t) p = [0] * n c = r = 0 max_len = 0 for i in range(n): mirror = 2 * c - i if i < r: p[i] = min(r - i, p[mirror]) a = i + p[i] + 1 b = i - p[i] - 1 while a < n and b >= 0 and t[a] == t[b]: p[i] += 1 a += 1 b -= 1 if i + p[i] > r: c, r = i, i + p[i] if p[i] > max_len: max_len = p[i] return max_len L = longest_palindrome(S) if L == len(S): print(L - 1) else: print(L)