結果
| 問題 | 
                            No.238 Mr. K's Another Gift
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-06-04 16:26:16 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 542 bytes | 
| コンパイル時間 | 208 ms | 
| コンパイル使用メモリ | 12,288 KB | 
| 実行使用メモリ | 22,016 KB | 
| 最終ジャッジ日時 | 2024-11-29 12:13:13 | 
| 合計ジャッジ時間 | 35,959 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 31 TLE * 9 | 
ソースコード
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)
            break
        elif is_palindrome(s2):
            print(s2)
            break
else:
    print('NA')