結果
| 問題 |
No.238 Mr. K's Another Gift
|
| コンテスト | |
| ユーザー |
reew2n
|
| 提出日時 | 2015-07-05 23:01:48 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 928 bytes |
| コンパイル時間 | 1,350 ms |
| コンパイル使用メモリ | 160,748 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-07 23:42:44 |
| 合計ジャッジ時間 | 3,756 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 WA * 6 |
ソースコード
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define F first
#define S second
#define PB push_back
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef vector<ut> VI;
const ut INF=1<<30;
const int SIZE=1e+6;
const ut eps=1e-9;
VI primes;
string answer;
bool solve(string str,int s,int e,bool used){
while(s<=e){
if(str[s]==str[e]){
s++;
e--;
}
else{
if(used) return false;
if(solve(str,s+1,e,true)){
str.insert(e+1,string(1,str[s]));
s++;
}
else if(solve(str,s,e-1,true)){
str.insert(s,string(1,str[e]));
e--;
}
else return false;
used=true;
}
}
if(!used){
str.insert((s+e)/2,string(1,str[(s+e)/2]));
}
answer=str;
return true;
}
int main(){
string s;
cin >> s;
int N=s.size();
if(solve(s,0,N-1,false)) cout << answer<<endl;
else cout << "NA" << endl;
return 0;
}
reew2n