結果
| 問題 |
No.238 Mr. K's Another Gift
|
| コンテスト | |
| ユーザー |
koyumeishi
|
| 提出日時 | 2015-07-05 22:52:18 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 877 bytes |
| コンパイル時間 | 510 ms |
| コンパイル使用メモリ | 76,072 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-07 23:32:52 |
| 合計ジャッジ時間 | 2,910 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 WA * 9 |
ソースコード
#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;
int main(){
string s;
cin >> s;
int n=s.size();
string r = s;
reverse(r.begin(), r.end());
bool valid = true;
int pos = -1;
for(int i=0; i<n; i++){
if(r[i] != s[i]){
valid = false;
pos = i;
break;
}
}
if(valid){
if(n%2 == 0){
cout << s.substr(0, n/2) << "a" << s.substr(n/2, n/2) << endl;
}else{
cout << "NA" << endl;
}
return 0;
}
string t = r.substr(0, pos);
t += s[pos];
t += r.substr(pos, string::npos);
r = t;
reverse(r.begin(), r.end());
valid = true;
for(int i=0; i<t.size(); i++){
if(r[i] != t[i]){
valid = false;
break;
}
}
if(valid){
cout << t << endl;
}else{
cout << "NA" << endl;
}
return 0;
}
koyumeishi