結果
| 問題 |
No.238 Mr. K's Another Gift
|
| コンテスト | |
| ユーザー |
codershifth
|
| 提出日時 | 2016-05-01 17:41:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,529 bytes |
| コンパイル時間 | 1,589 ms |
| コンパイル使用メモリ | 163,044 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-05 00:39:21 |
| 合計ジャッジ時間 | 5,648 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 20 WA * 20 |
ソースコード
#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<<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