結果
問題 |
No.238 Mr. K's Another Gift
|
ユーザー |
|
提出日時 | 2016-01-30 00:34:03 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,101 bytes |
コンパイル時間 | 738 ms |
コンパイル使用メモリ | 92,392 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-21 18:54:04 |
合計ジャッジ時間 | 3,612 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 WA * 3 |
ソースコード
#include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> using namespace std; bool check(const string& s) { string t = s; reverse(t.begin(), t.end()); return s == t; } int main() { string s; cin >> s; int n = s.size(); int i = 0; while(i < n / 2 && s[i] == s[n-1-i]) ++ i; if(i < n / 2){ string t = s; t.insert(t.begin() + i, s[n-1-i]); if(check(t)){ cout << t << endl; return 0; } t = s; t.insert(t.begin() + n - i, s[i]); if(check(t)){ cout << t << endl; return 0; } } else if(n % 2 == 0){ s.insert(s.begin() + n / 2, 'a'); cout << s << endl; return 0; } cout << "NA" << endl; return 0; }