結果
| 問題 | No.238 Mr. K's Another Gift |
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-17 13:39:19 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 101 ms / 2,000 ms |
| コード長 | 683 bytes |
| 記録 | |
| コンパイル時間 | 352 ms |
| コンパイル使用メモリ | 20,700 KB |
| 実行使用メモリ | 17,372 KB |
| 最終ジャッジ日時 | 2026-05-24 07:52:48 |
| 合計ジャッジ時間 | 6,917 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#!/usr/bin/env python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def gen_cand(S):
L = 0
R = len(S) - 1
while True:
if L == R:
yield (L, S[L])
break
if R == L - 1:
yield (L, 'a')
break
if S[L] != S[R]:
yield (L, S[R])
yield (R + 1, S[L])
break
else:
L += 1
R -= 1
S = list(read().rstrip().decode())
for i, x in gen_cand(S):
T = S[:]
T.insert(i, x)
word = ''.join(T)
if word == word[::-1]:
print(word)
exit()
print('NA')
maspy