結果

問題 No.273 回文分解
ユーザー lloyzlloyz
提出日時 2023-03-15 00:04:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 340 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 81,756 KB
実行使用メモリ 66,388 KB
最終ジャッジ日時 2023-10-18 12:09:22
合計ジャッジ時間 4,139 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,460 KB
testcase_01 AC 41 ms
59,084 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 42 ms
59,084 KB
testcase_06 AC 42 ms
59,084 KB
testcase_07 AC 38 ms
53,460 KB
testcase_08 AC 45 ms
59,152 KB
testcase_09 AC 45 ms
59,084 KB
testcase_10 AC 38 ms
53,460 KB
testcase_11 AC 37 ms
53,460 KB
testcase_12 AC 37 ms
53,460 KB
testcase_13 AC 37 ms
53,460 KB
testcase_14 AC 50 ms
64,440 KB
testcase_15 AC 37 ms
53,460 KB
testcase_16 AC 37 ms
53,460 KB
testcase_17 AC 37 ms
53,460 KB
testcase_18 AC 37 ms
53,460 KB
testcase_19 AC 42 ms
59,084 KB
testcase_20 AC 37 ms
53,460 KB
testcase_21 AC 38 ms
53,460 KB
testcase_22 AC 50 ms
66,388 KB
testcase_23 AC 50 ms
66,388 KB
testcase_24 AC 50 ms
66,388 KB
testcase_25 AC 50 ms
66,388 KB
testcase_26 AC 51 ms
66,388 KB
testcase_27 AC 52 ms
66,388 KB
testcase_28 AC 51 ms
66,388 KB
testcase_29 AC 45 ms
61,200 KB
testcase_30 AC 51 ms
66,388 KB
testcase_31 AC 37 ms
53,460 KB
testcase_32 AC 37 ms
53,460 KB
testcase_33 AC 37 ms
53,460 KB
testcase_34 AC 38 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = list(input())

def f(s):
    n = len(s)
    rs = [None for _ in range(n)]
    for i in range(n):
        rs[i] = s[n - i - 1]
    return s == rs
ans = 1
n = len(s)
for i in range(n):
    for j in range(i + 1, n):
        if j - i == n - 1:
            continue
        if f(s[i:j + 1]):
            ans = max(ans, j - i + 1)
print(ans)
0