結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,016 KB
testcase_01 AC 16 ms
8,008 KB
testcase_02 AC 16 ms
8,040 KB
testcase_03 AC 16 ms
8,056 KB
testcase_04 AC 17 ms
8,048 KB
testcase_05 WA -
testcase_06 AC 38 ms
8,216 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 15 ms
7,788 KB
testcase_11 AC 15 ms
7,804 KB
testcase_12 AC 16 ms
7,804 KB
testcase_13 AC 15 ms
7,808 KB
testcase_14 AC 28 ms
8,096 KB
testcase_15 AC 43 ms
8,292 KB
testcase_16 AC 44 ms
8,156 KB
testcase_17 AC 17 ms
8,536 KB
testcase_18 AC 20 ms
8,320 KB
testcase_19 AC 16 ms
8,156 KB
testcase_20 AC 16 ms
8,088 KB
testcase_21 AC 15 ms
8,064 KB
testcase_22 AC 15 ms
8,092 KB
testcase_23 AC 16 ms
8,048 KB
testcase_24 AC 18 ms
8,032 KB
testcase_25 AC 20 ms
8,088 KB
testcase_26 AC 41 ms
8,180 KB
testcase_27 WA -
testcase_28 AC 40 ms
8,156 KB
testcase_29 WA -
testcase_30 AC 16 ms
7,876 KB
testcase_31 AC 16 ms
7,780 KB
testcase_32 AC 15 ms
7,840 KB
testcase_33 AC 17 ms
7,972 KB
testcase_34 AC 16 ms
8,308 KB
testcase_35 AC 40 ms
8,400 KB
testcase_36 AC 19 ms
8,416 KB
testcase_37 AC 31 ms
8,344 KB
testcase_38 AC 18 ms
8,508 KB
testcase_39 AC 16 ms
8,196 KB
testcase_40 AC 16 ms
7,992 KB
testcase_41 AC 15 ms
8,068 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 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-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