結果
| 問題 |
No.273 回文分解
|
| コンテスト | |
| ユーザー |
c-yan
|
| 提出日時 | 2021-01-18 00:14:31 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 429 bytes |
| コンパイル時間 | 166 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 21,248 KB |
| 最終ジャッジ日時 | 2024-11-30 06:47:12 |
| 合計ジャッジ時間 | 11,019 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 TLE * 3 |
ソースコード
def is_palindrome(s):
return s == s[::-1]
def f(s):
if len(s) == 1:
return 1
result = 0
for i in range(1, len(s)):
a, b = s[:i], s[i:]
if not is_palindrome(a):
continue
result = max(result, len(a))
if is_palindrome(b):
result = max(result, len(b))
else:
result = max(result, f(b))
return result
S = input()
print(f(S))
c-yan