問題一覧 > 通常問題

No.238 Mr. K's Another Gift

レベル : / AI推定難易度 : 800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 256 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 142
作問者 : evima
お気に入りにしたユーザー ProblemId : 591 / 自分の提出
問題文最終更新日: 2026-06-25 01:48:28
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 113 (順位表) の他の問題:

Problem Statement

(This problem is Problem A of Codeforces Round #286 (Div. 2) with modified input constraints.)

Mr. K gave you a string $s$ consisting of lowercase English letters. He wants you to insert exactly one lowercase English letter into it to make it a palindrome.
(A palindrome is a string in which the characters appear in the same order whether read from the front or from the back.
For example, "noon", "testset", and "a" are all palindromes, but "test" and "kitayuta" are not.)

You may choose any lowercase English letter as the character to insert, and you may insert it at any position in $s$.
Insertion at the beginning or the end of $s$ is also allowed.
Even if the given string $s$ is already a palindrome, you must insert one character.

If it is possible to insert one lowercase English letter into $s$ so that the resulting string is a palindrome, output one palindrome obtainable in this way.
Otherwise, output "NA" (without quotes) in uppercase.
If there are multiple obtainable palindromes, you may output any of them.

Input

$s$

  • $1 \le |s| \le 10^5$
  • Each character of $s$ is a lowercase English letter.

Output

If it is possible to make $s$ a palindrome by inserting one lowercase English letter, output one palindrome obtainable in this way.
Otherwise, output "NA" (without quotes) in uppercase.
If there are multiple solutions, any of them will be accepted.

Sample

Sample 1
Input
revive
Output
reviver

Inserting 'r' at the end makes it a palindrome.

Sample 2
Input
ee
Output
eye

There are multiple solutions for this input. For example, outputting "eve" is also accepted.

Sample 3
Input
kitayuta
Output
NA

It cannot be made a palindrome by inserting just one character.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。