結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,020 KB
testcase_01 AC 16 ms
8,124 KB
testcase_02 AC 16 ms
8,100 KB
testcase_03 AC 16 ms
7,992 KB
testcase_04 AC 17 ms
8,088 KB
testcase_05 WA -
testcase_06 AC 39 ms
8,180 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 17 ms
7,772 KB
testcase_11 AC 17 ms
7,808 KB
testcase_12 AC 17 ms
7,868 KB
testcase_13 AC 16 ms
7,856 KB
testcase_14 AC 28 ms
8,088 KB
testcase_15 AC 46 ms
8,236 KB
testcase_16 AC 44 ms
8,276 KB
testcase_17 AC 18 ms
8,420 KB
testcase_18 AC 21 ms
8,312 KB
testcase_19 AC 16 ms
8,180 KB
testcase_20 AC 16 ms
8,068 KB
testcase_21 AC 16 ms
8,040 KB
testcase_22 AC 16 ms
8,072 KB
testcase_23 AC 16 ms
8,008 KB
testcase_24 AC 18 ms
8,156 KB
testcase_25 AC 21 ms
8,156 KB
testcase_26 AC 39 ms
8,184 KB
testcase_27 WA -
testcase_28 AC 39 ms
8,248 KB
testcase_29 WA -
testcase_30 AC 15 ms
7,780 KB
testcase_31 AC 16 ms
7,888 KB
testcase_32 AC 16 ms
7,828 KB
testcase_33 AC 17 ms
8,016 KB
testcase_34 AC 16 ms
8,296 KB
testcase_35 AC 38 ms
8,284 KB
testcase_36 AC 19 ms
8,444 KB
testcase_37 AC 31 ms
8,372 KB
testcase_38 AC 18 ms
8,536 KB
testcase_39 AC 16 ms
8,228 KB
testcase_40 AC 16 ms
8,084 KB
testcase_41 AC 16 ms
8,012 KB
testcase_42 AC 16 ms
7,772 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]+S[N-1-index]+S[index:]
    N = len(tmp_s)
    for j in range(len(tmp_s)):
        if tmp_s[j] != tmp_s[N-1-j]:
            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-index]+S[index]+S[N-1-index+1:]
    N = len(tmp_s)
    for k in range(len(tmp_s)):
        if tmp_s[k] != tmp_s[N-1-k]:
            break
    else:
        print(tmp_s)
        exit()
print("NA")
0