結果
| 問題 |
No.238 Mr. K's Another Gift
|
| コンテスト | |
| ユーザー |
kongarishisyamo
|
| 提出日時 | 2016-02-28 18:27:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 683 bytes |
| コンパイル時間 | 605 ms |
| コンパイル使用メモリ | 57,268 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 12:07:31 |
| 合計ジャッジ時間 | 2,153 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#include<iostream>
#include<string>
using namespace std;
int main(){
string s;
string ins="";
int ini=0;
int soe=-1;
cin>>s;
int st=0,en=s.size()-1;
bool f=false;
while(st<=en){
if(s[st]!=s[en]){
if(f){
cout<<"NA"<<endl;
return 0;
}
f=true;
if(s[st+1]==s[en]){
ini=en,ins=s[st];
st++;
soe=1;
}
else if(s[st]==s[en-1]){
ini=st,ins=s[en];
en--;
soe=0;
}
else{
cout<<"NA"<<endl;
return 0;
}
}
else st++,en--;
}
if(!f){
ini=s.size()/2;
ins=s[s.size()/2];
soe=1;
}
for(int i=0;i<s.size();i++){
if(i==ini&&soe==0) cout<<ins;
cout<<s[i];
if(i==ini&&soe==1) cout<<ins;
}
cout<<endl;
}
kongarishisyamo