結果
| 問題 |
No.238 Mr. K's Another Gift
|
| コンテスト | |
| ユーザー |
codershifth
|
| 提出日時 | 2016-05-01 17:48:31 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,579 bytes |
| コンパイル時間 | 1,243 ms |
| コンパイル使用メモリ | 164,788 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-05 00:40:23 |
| 合計ジャッジ時間 | 4,347 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 24 WA * 16 |
ソースコード
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()
using namespace std;
class MrKsAnotherGift
{
public:
void solve(void)
{
string s;
cin>>s;
int N = s.length();
string ans[2];
bool inserted = false;
for (int i = 0; i < N/2; ++i)
{
if ( s[i] != s[N-1-i] )
{
if ( inserted )
{
cout<<"NA"<<endl;
return;
}
ans[0] = s.substr(0,i) + string(1,s[N-1-i]) + s.substr(i,N);
ans[1] = s.substr(0,N-1-i) + string(1,s[i]) + s.substr(N-1-i,N);
inserted = true;
}
}
if ( !inserted )
{
cout<<(s.substr(0,N/2) + string(1,'a') + s.substr(N/2,N))<<endl;
return;
}
bool ok[2] = {true,true};
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < 2; ++j)
{
if ( ans[i] != ans[N-1-i] )
ok[j] = false;
}
}
if ( ok[0] )
cout<<ans[0]<<endl;
else if ( ok[1] )
cout<<ans[1]<<endl;
else
cout<<"NA"<<endl;
}
};
#if 1
int main(int argc, char *argv[])
{
ios::sync_with_stdio(false);
auto obj = new MrKsAnotherGift();
obj->solve();
delete obj;
return 0;
}
#endif
codershifth