結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,144 KB
testcase_01 AC 17 ms
8,092 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 16 ms
8,136 KB
testcase_05 WA -
testcase_06 AC 39 ms
8,276 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 16 ms
7,864 KB
testcase_11 AC 15 ms
7,812 KB
testcase_12 AC 14 ms
7,908 KB
testcase_13 AC 16 ms
7,804 KB
testcase_14 AC 23 ms
8,092 KB
testcase_15 AC 41 ms
8,200 KB
testcase_16 AC 39 ms
8,184 KB
testcase_17 AC 16 ms
8,416 KB
testcase_18 AC 20 ms
8,384 KB
testcase_19 AC 16 ms
8,228 KB
testcase_20 AC 15 ms
8,068 KB
testcase_21 AC 14 ms
8,144 KB
testcase_22 AC 14 ms
8,012 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 40 ms
8,268 KB
testcase_27 WA -
testcase_28 AC 38 ms
8,268 KB
testcase_29 WA -
testcase_30 AC 15 ms
7,768 KB
testcase_31 AC 16 ms
7,808 KB
testcase_32 AC 15 ms
7,772 KB
testcase_33 AC 17 ms
8,024 KB
testcase_34 AC 15 ms
8,184 KB
testcase_35 AC 37 ms
8,392 KB
testcase_36 AC 18 ms
8,452 KB
testcase_37 AC 25 ms
8,272 KB
testcase_38 AC 18 ms
8,444 KB
testcase_39 AC 15 ms
8,244 KB
testcase_40 AC 16 ms
8,044 KB
testcase_41 AC 15 ms
8,112 KB
testcase_42 AC 15 ms
7,768 KB
権限があれば一括ダウンロードができます

ソースコード

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)):
        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)):
        if tmp_s[i] != tmp_s[N-1-i]:
            break
    else:
        print(tmp_s)
        exit()
print("NA")
0