#include<bits/stdc++.h>
using namespace std;
string Str;
int Pos[200],PosX=0;
char X;
int main()
{
while (cin>>Str)
{
memset(Pos,-1,sizeof(Pos));
for (int i=0; i<Str.length(); i++)
if (Pos[Str[i]]==-1)
Pos[Str[i]]=i;
else
X=Str[i],PosX=i;
if (PosX-Pos[X]==1)
{
cout<<"Impossible";
return 0;
}
int temp=PosX-Pos[X]-1;
string q="",w="",e="";
q=q+Str[Pos[X]];
for (int i=1;i<=temp/2;i++)
q=q+Str[Pos[X]+i];
for (int i=temp/2+1;i<=temp;i++)
w=Str[Pos[X]+i]+w;
for (int i=PosX+1;i<=26;i++)
e=e+Str[i];
for (int i=0;i<=Pos[X]-1;i++)
e=e+Str[i];
string e1=e.substr(0,12-temp/2);
string e2=e.substr(12-temp/2,e.length()-(12-temp/2));
reverse(e1.begin(),e1.end());
q=e1+q;
w=e2+w;
cout<<q<<endl<<w<<endl;
}
return 0;
}
CodeForces 725C HiddenWord 字符串构造
最新推荐文章于 2016-11-25 19:24:00 发布