結果

問題 No.238 Mr. K's Another Gift
ユーザー masa
提出日時 2015-07-05 23:43:27
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 561 bytes
コンパイル時間 443 ms
コンパイル使用メモリ 61,636 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-08 00:58:37
合計ジャッジ時間 2,648 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	string s1, s2;

	cin >> s1;
	s2 = s1;
	reverse(s2.begin(), s2.end());
	int n = s1.size();

	for (int i = 0; i <= n / 2; i++) {
		if (s1[i] != s2[i]) {
			s2.insert(i, 1, s1[i]);
			break;
		}
	}

	s1 = s2;
	reverse(s1.begin(), s1.end());

	if (s1 != s2) {
		cout << "NA" << endl;
		return 0;
	}

	if (s1.size() == n) {
		int idx = n / 2;
		s1.insert(idx + 1, 1, s1[idx]);
	}

	cout << s1 << endl;
	return 0;
}
0