結果
問題 |
No.765 ukuku 2
|
ユーザー |
![]() |
提出日時 | 2025-04-24 12:26:12 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 647 bytes |
コンパイル時間 | 146 ms |
コンパイル使用メモリ | 82,164 KB |
実行使用メモリ | 81,756 KB |
最終ジャッジ日時 | 2025-04-24 12:27:36 |
合計ジャッジ時間 | 3,906 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)