結果

問題 No.2234 palindromer
ユーザー lloyzlloyz
提出日時 2023-03-12 18:54:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 541 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 81,884 KB
実行使用メモリ 53,572 KB
最終ジャッジ日時 2023-10-18 10:43:52
合計ジャッジ時間 1,660 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,572 KB
testcase_01 AC 38 ms
53,572 KB
testcase_02 AC 38 ms
53,572 KB
testcase_03 AC 38 ms
53,572 KB
testcase_04 AC 37 ms
53,572 KB
testcase_05 AC 38 ms
53,572 KB
testcase_06 AC 38 ms
53,572 KB
testcase_07 AC 38 ms
53,572 KB
testcase_08 AC 37 ms
53,572 KB
testcase_09 AC 40 ms
53,572 KB
testcase_10 AC 37 ms
53,572 KB
testcase_11 AC 39 ms
53,572 KB
testcase_12 AC 38 ms
53,572 KB
testcase_13 AC 38 ms
53,572 KB
testcase_14 AC 37 ms
53,572 KB
testcase_15 AC 38 ms
53,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()

n = len(s)
res = ''
for i in range(n - 1):
    res += s[i]
    res += '$'
res += s[n - 1]
m = len(res)
mid = m // 2
for i in range(mid, m):
    l, r = i - 1, i + 1
    flag = True
    while l >= 0 and r < m:
        if res[l] != res[r]:
            flag = False
            break
        l -= 1
        r += 1
    if flag:
        l, r = i - 1, i + 1
        ans = s
        while l >= 0:
            if l % 2 == 0 and r >= m:
                ans += res[l]
            l -= 1
            r += 1
        print(ans)
        break
0