結果
問題 | No.238 Mr. K's Another Gift |
ユーザー |
![]() |
提出日時 | 2020-03-17 13:39:19 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 683 bytes |
コンパイル時間 | 80 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 13,184 KB |
最終ジャッジ日時 | 2024-11-30 16:57:37 |
合計ジャッジ時間 | 3,921 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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')