Submission #3431047
Source Code Expand
/*input
xabxa
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
out<<'('<<P.F<<','<<P.S<<')';
return out;
}
//}}}
const ll maxn=500005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;
ll mypow(ll a,ll b){
ll res=1LL;
while(b){
if(b&1) res=res*a%MOD;
a=a*a%MOD;
b>>=1;
}
return res;
}
string s,t;
int main()
{
IOS;
cin>>s;
REP(i,SZ(s)) if(s[i]!='x')t.pb(s[i]);
{
string rev=t;
reverse(ALL(rev));
if(rev!=t){
cout<<"-1\n";
return 0;
}
}
s="c"+s;
s.pb('c');
int l=0;
vector<int> v;
REP(i,SZ(s)) if(i){
if(s[i]!='x'){
v.pb(i-l-1);
l=i;
}
}
for(int i=0,j=SZ(v)-1;i<j;i++,j--){
v[i]=max(v[i],v[j]);
v[j]=max(v[i],v[j]);
}
REP(i,SZ(v)){
REP(I,v[i]) cout<<'x';
if(i!=SZ(v)-1) cout<<t[i];
}
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Inserting 'x' |
User |
iloveUtaha |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2051 Byte |
Status |
WA |
Exec Time |
7 ms |
Memory |
1260 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 400 |
Status |
|
|
Set Name |
Test Cases |
Sample |
0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All |
0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt |
Case Name |
Status |
Exec Time |
Memory |
0_00.txt |
WA |
1 ms |
256 KB |
0_01.txt |
AC |
1 ms |
256 KB |
0_02.txt |
WA |
1 ms |
256 KB |
0_03.txt |
WA |
1 ms |
256 KB |
1_00.txt |
WA |
1 ms |
256 KB |
1_01.txt |
WA |
1 ms |
256 KB |
1_02.txt |
WA |
1 ms |
256 KB |
1_03.txt |
WA |
1 ms |
256 KB |
1_04.txt |
WA |
1 ms |
256 KB |
1_05.txt |
WA |
1 ms |
256 KB |
1_06.txt |
WA |
5 ms |
1260 KB |
1_07.txt |
WA |
4 ms |
512 KB |
1_08.txt |
WA |
5 ms |
1260 KB |
1_09.txt |
WA |
4 ms |
512 KB |
1_10.txt |
WA |
6 ms |
620 KB |
1_11.txt |
WA |
6 ms |
620 KB |
1_12.txt |
WA |
6 ms |
1260 KB |
1_13.txt |
WA |
4 ms |
512 KB |
1_14.txt |
WA |
5 ms |
512 KB |
1_15.txt |
WA |
4 ms |
512 KB |
1_16.txt |
AC |
1 ms |
512 KB |
1_17.txt |
WA |
5 ms |
512 KB |
1_18.txt |
AC |
1 ms |
512 KB |
1_19.txt |
WA |
5 ms |
512 KB |
1_20.txt |
AC |
1 ms |
512 KB |
1_21.txt |
WA |
6 ms |
748 KB |
1_22.txt |
AC |
2 ms |
512 KB |
1_23.txt |
WA |
6 ms |
1004 KB |
1_24.txt |
AC |
2 ms |
512 KB |
1_25.txt |
WA |
7 ms |
1004 KB |
1_26.txt |
AC |
2 ms |
512 KB |
1_27.txt |
WA |
5 ms |
1260 KB |
1_28.txt |
AC |
2 ms |
592 KB |