結果

問題 No.238 Mr. K's Another Gift
ユーザー H3PO4H3PO4
提出日時 2020-06-04 16:28:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 536 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 10,804 KB
実行使用メモリ 8,496 KB
最終ジャッジ日時 2023-08-19 17:57:55
合計ジャッジ時間 3,854 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,104 KB
testcase_01 AC 15 ms
7,812 KB
testcase_02 AC 15 ms
7,808 KB
testcase_03 AC 15 ms
7,796 KB
testcase_04 AC 15 ms
7,964 KB
testcase_05 AC 25 ms
8,288 KB
testcase_06 AC 24 ms
8,080 KB
testcase_07 AC 32 ms
8,248 KB
testcase_08 AC 33 ms
8,388 KB
testcase_09 AC 47 ms
8,140 KB
testcase_10 AC 15 ms
7,804 KB
testcase_11 AC 16 ms
7,784 KB
testcase_12 AC 16 ms
7,768 KB
testcase_13 AC 15 ms
7,784 KB
testcase_14 AC 25 ms
8,044 KB
testcase_15 AC 42 ms
8,092 KB
testcase_16 AC 42 ms
8,152 KB
testcase_17 AC 17 ms
8,408 KB
testcase_18 AC 20 ms
8,392 KB
testcase_19 AC 16 ms
8,148 KB
testcase_20 AC 15 ms
7,752 KB
testcase_21 AC 16 ms
7,776 KB
testcase_22 AC 15 ms
7,940 KB
testcase_23 AC 15 ms
7,808 KB
testcase_24 AC 17 ms
7,812 KB
testcase_25 AC 18 ms
8,000 KB
testcase_26 AC 23 ms
8,156 KB
testcase_27 AC 41 ms
8,288 KB
testcase_28 AC 23 ms
8,164 KB
testcase_29 AC 43 ms
8,188 KB
testcase_30 AC 15 ms
7,812 KB
testcase_31 AC 15 ms
7,804 KB
testcase_32 AC 16 ms
7,812 KB
testcase_33 AC 16 ms
7,912 KB
testcase_34 AC 16 ms
8,112 KB
testcase_35 AC 38 ms
8,244 KB
testcase_36 AC 21 ms
8,360 KB
testcase_37 AC 29 ms
8,404 KB
testcase_38 AC 20 ms
8,496 KB
testcase_39 AC 15 ms
8,140 KB
testcase_40 AC 15 ms
7,904 KB
testcase_41 AC 15 ms
7,996 KB
testcase_42 AC 15 ms
7,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
L = len(S)


def is_palindrome(s):
    for i in range(len(s) // 2):
        if s[i] != s[len(s) - 1 - i]:
            return False
    return True


if is_palindrome(S):
    print(S[:L // 2] + S[L // 2] + S[L // 2:])
    exit()

for i in range(L // 2):
    if S[i] != S[L - 1 - i]:
        s1 = S[:i] + S[L - 1 - i] + S[i:]
        s2 = S[:L - i] + S[i] + S[L - i:]
        if is_palindrome(s1):
            print(s1)
        elif is_palindrome(s2):
            print(s2)
        else:
            print('NA')
        break
0