結果

問題 No.273 回文分解
コンテスト
ユーザー tookunn_1213
提出日時 2016-07-06 23:22:46
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 333 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 474 ms
コンパイル使用メモリ 20,824 KB
実行使用メモリ 15,484 KB
最終ジャッジ日時 2026-03-11 22:11:20
合計ジャッジ時間 5,011 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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)
0