結果
問題 |
No.273 回文分解
|
ユーザー |
![]() |
提出日時 | 2016-07-06 23:22:46 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 333 bytes |
コンパイル時間 | 89 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-06-25 13:37:28 |
合計ジャッジ時間 | 2,153 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
S = input() N = len(S) ans = 0 def isPalindrome(p): s,t,c = 0,len(p) - 1,0 while s < t and p[s] == p[t]: s,t,c= s + 1,t - 1,c + 2 if s == t and p[s] == p[t]: c += 1 return c == len(p) for i in range(N): for j in range(i,N): if len(S[i:j + 1]) < N and isPalindrome(S[i:j + 1]): ans = max(ans,len(S[i:j + 1])) print (ans)