結果

問題 No.238 Mr. K's Another Gift
ユーザー yuruhiyayuruhiya
提出日時 2020-09-03 17:54:28
言語 Ruby
(3.3.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 304 bytes
コンパイル時間 124 ms
コンパイル使用メモリ 11,396 KB
実行使用メモリ 15,936 KB
最終ジャッジ日時 2023-08-15 13:03:12
合計ジャッジ時間 6,467 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,080 KB
testcase_01 AC 81 ms
15,292 KB
testcase_02 AC 80 ms
15,076 KB
testcase_03 AC 80 ms
15,300 KB
testcase_04 AC 83 ms
15,048 KB
testcase_05 AC 84 ms
15,676 KB
testcase_06 AC 102 ms
15,832 KB
testcase_07 AC 89 ms
15,720 KB
testcase_08 AC 89 ms
15,768 KB
testcase_09 AC 97 ms
15,436 KB
testcase_10 AC 81 ms
15,244 KB
testcase_11 AC 80 ms
15,248 KB
testcase_12 AC 80 ms
15,232 KB
testcase_13 AC 80 ms
15,244 KB
testcase_14 AC 88 ms
15,584 KB
testcase_15 AC 95 ms
15,588 KB
testcase_16 AC 95 ms
15,584 KB
testcase_17 AC 82 ms
15,936 KB
testcase_18 AC 84 ms
15,824 KB
testcase_19 AC 80 ms
15,792 KB
testcase_20 AC 79 ms
15,040 KB
testcase_21 AC 78 ms
15,148 KB
testcase_22 AC 79 ms
15,268 KB
testcase_23 AC 80 ms
15,120 KB
testcase_24 AC 84 ms
15,248 KB
testcase_25 AC 81 ms
15,264 KB
testcase_26 AC 101 ms
15,640 KB
testcase_27 AC 94 ms
15,552 KB
testcase_28 AC 101 ms
15,628 KB
testcase_29 AC 95 ms
15,456 KB
testcase_30 AC 80 ms
15,156 KB
testcase_31 AC 79 ms
15,148 KB
testcase_32 AC 81 ms
15,236 KB
testcase_33 AC 81 ms
15,272 KB
testcase_34 AC 80 ms
15,768 KB
testcase_35 AC 93 ms
15,616 KB
testcase_36 AC 82 ms
15,812 KB
testcase_37 AC 85 ms
15,608 KB
testcase_38 AC 84 ms
15,776 KB
testcase_39 AC 80 ms
15,604 KB
testcase_40 AC 81 ms
15,040 KB
testcase_41 AC 80 ms
15,044 KB
testcase_42 AC 80 ms
15,084 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

s = gets.chomp
n, m = s.size, s.size / 2
pos = (0...m).find { s[_1] != s[~_1] }
if pos
	t = s[pos..~pos]
	if x = [t + t[0], t[-1] + t].find{ _1 == _1.reverse }
		s[pos..~pos] = x
		puts s
	else
		puts 'NA'
	end
else
	if n.even?
		puts s[...m] + 'a' + s[m..]
	else
		puts s[...m] + s[m] + s[m..]
	end
end
0