結果
| 問題 |
No.238 Mr. K's Another Gift
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-07-05 23:47:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 933 bytes |
| コンパイル時間 | 1,123 ms |
| コンパイル使用メモリ | 160,232 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-08 01:01:27 |
| 合計ジャッジ時間 | 2,577 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
bool pal(string s) {
rep (i, s.length()) {
if (s[i] != s[s.length() - i - 1]) {
return false;
}
}
return true;
}
int main() {
string s;
cin >> s;
string t = s;
reverse(t.begin(), t.end());
int pos = s.length() / 2;
rep (i, s.length()) {
if (s[i] != t[i]) {
pos = i;
break;
}
}
string ansA = t;
string ansB = t;
ansA.insert(pos, string(1, ansA[ansA.length() - pos - 1]));
ansB.insert(ansB.length() - pos, string(1, ansB[pos]));
if (pal(ansA)) {
cout << ansA << endl;
} else if (pal(ansB)) {
cout << ansB << endl;
} else {
cout << "NA" << endl;
}
}