結果

問題 No.2234 palindromer
ユーザー FromBooskaFromBooska
提出日時 2023-10-03 09:07:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 464 bytes
コンパイル時間 475 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 71,544 KB
最終ジャッジ日時 2023-10-03 09:07:13
合計ジャッジ時間 3,611 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,224 KB
testcase_01 AC 71 ms
71,368 KB
testcase_02 AC 69 ms
71,544 KB
testcase_03 AC 71 ms
71,484 KB
testcase_04 AC 72 ms
71,200 KB
testcase_05 AC 69 ms
71,240 KB
testcase_06 AC 67 ms
71,196 KB
testcase_07 AC 69 ms
71,540 KB
testcase_08 AC 69 ms
71,384 KB
testcase_09 AC 69 ms
71,224 KB
testcase_10 AC 72 ms
71,204 KB
testcase_11 AC 70 ms
71,208 KB
testcase_12 AC 69 ms
71,156 KB
testcase_13 AC 70 ms
71,196 KB
testcase_14 AC 70 ms
71,384 KB
testcase_15 AC 70 ms
71,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# N小さい、愚直に全チェックすればいい
# 最短でmid=N//2までをそのあと繰り返す、それで合致するか調べればいい

S = input()
N = len(S)
mid = (N+1)//2
for i in range(mid, N+1):
    s = S[:i]
    s1 = s + s[:-1][::-1]
    s2 = s + s[::-1]
    #print(i, s, s1, s1[:N], s2, s2[:N])
    if len(s1) >= N and s1[:N] == S:
        print(s1)
        break
    if len(s2) >= N and s2[:N] == S:
        print(s2)  
        break
    
0