結果
| 問題 |
No.238 Mr. K's Another Gift
|
| コンテスト | |
| ユーザー |
wkwkes
|
| 提出日時 | 2015-07-05 23:31:34 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 203 ms / 2,000 ms |
| コード長 | 1,586 bytes |
| コンパイル時間 | 805 ms |
| コンパイル使用メモリ | 77,240 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-08 00:27:24 |
| 合計ジャッジ時間 | 2,629 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#include <cmath>
#define INF 10000000000
#define MOD 10000000007
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef pair<int, int> i_i;
int main(){
string s;
cin >> s;
int ch = 0;
string h=s;
int a=0,b=s.length()-1;
if(b==0){
cout <<s+s<<endl;
return 0;
}
while(a<=b){
if (s[a]==s[b]) {
a++;
b--;
continue;
}else{
if (s[a+1]==s[b]) {
h = h.substr(0,b+1)+s[a]+s.substr(b+1,s.length()-b);
ch++;
a++;
continue;
}
if (s[a]==s[b-1]) {
h = h.substr(0,a)+s[b]+s.substr(a,s.length()-a);
ch++;
b--;
continue;
}
a++;
b--;
ch+=10;
}
}
if (ch==1) {
cout << h << endl;
return 0;
}
if (ch == 0) {
string ans = "";
if (h.length()%2==0) {
ans = h.substr(0,h.length()/2)+"a"+h.substr(h.length()/2,h.length()/2);
}else{
ans = h.substr(0,h.length()/2)+h[h.length()/2]+h.substr(h.length()/2,h.length()/2+1);
}
cout << ans << endl;
return 0;
}
if(ch>1) cout << "NA" <<endl;
}
wkwkes