結果

問題 No.238 Mr. K's Another Gift
ユーザー sugar_sentansugar_sentan
提出日時 2019-12-12 19:31:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,056 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 10,752 KB
実行使用メモリ 8,552 KB
最終ジャッジ日時 2023-09-07 19:28:10
合計ジャッジ時間 7,450 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,148 KB
testcase_01 AC 16 ms
8,028 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 18 ms
8,068 KB
testcase_05 WA -
testcase_06 AC 40 ms
8,208 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 16 ms
8,148 KB
testcase_21 AC 16 ms
8,036 KB
testcase_22 AC 15 ms
8,028 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 41 ms
8,196 KB
testcase_27 WA -
testcase_28 AC 39 ms
8,244 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 16 ms
8,036 KB
testcase_41 AC 16 ms
8,032 KB
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
N = len(S)
flag = True
for i in range(N):
    if S[i] != S[N-1-i]:
        flag = False
        break
index = i
# 引っかかったインデックスが手に入る
# S[i]をS[len(S)-1-i]の後ろに挿入するか, S[len(S)-1-i]をS[i]の前に挿入するかの二択
if flag:
    print(S[:N//2]+S[N//2]+S[N//2:])
    exit()
else:
    # 引っかかった場所の前に挿入するパターン
    # iが0の時に困る
    if index == 0:
        tmp_s = S[N-1-index]+S[index:]
    else:
        tmp_s = S[:index-1]+S[N-1-index]+S[index:]
    N = len(tmp_s)
    for i in range(len(tmp_s)//2):
        if tmp_s[i] != tmp_s[N-1-i]:
            break
    else:
        print(tmp_s)
        exit()

    # S[i]をS[len(S)-1-i]の後ろに挿入するパターン
    if index == 0:
        tmp_s = S + S[index]
    else:
        tmp_s = S[:N-1-index]+S[index]+S[N-1-index+1:]
    N = len(tmp_s)
    for i in range(len(tmp_s)//2):
        if tmp_s[i] != tmp_s[N-1-i]:
            break
    else:
        print(tmp_s)
        exit()
print("N/A")
0