链接:http://codeforces.com/contest/725/problem/C
Each English letter occurs at least once in s.!!
没看见!! 然后写爆搜剪枝写到爆炸
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
inline char nc(){
static char buf[100000],*p1=buf,*p2=buf;
if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; }
return *p1++;
}
inline void read(int &x){
char c=nc(),b=1;
for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
inline void read(char *s){
char c=nc(); int len=0;
for (;!(c>='A' && c<='Z');c=nc());
for (;c>='A' && c<='Z';s[++len]=c,c=nc());
}
int n=2,m=13;
char Map[3][20];
int cnt[27],pre[27];
int a,b,c;
char str[199];
int main(){
freopen("t.in","r",stdin);
freopen("t.out","w",stdout);
read(str);
for (int i=1;i<=27;i++){
cnt[str[i]-'A']++;
if (cnt[str[i]-'A']==2)
a=pre[str[i]-'A'],b=i;
pre[str[i]-'A']=i;
}
c=b-a-1;
if (!c) return printf("Impossible\n"),0;
int tem=c>>1,pnt=a+1;
Map[2][tem+1]=str[a];
for (int i=tem;i;i--)
Map[2][i]=str[pnt++];
int d;
for (int i=1;pnt<b;i++){
Map[1][i]=str[pnt++];
if (pnt==b) d=i;
}
int t=2;
for (int i=a-1,j=tem+2;i;i--){
if (j==14) j=13,t=1;
if (t==2){
Map[2][j++]=str[i];
}else
Map[1][j--]=str[i];
}
t=1;
for (int i=b+1,j=d+1;i<=27;i++){
if (t==1){
Map[1][j++]=str[i];
if (j==14) j=13,t=2;
}else
Map[2][j--]=str[i];
}
for (int i=1;i<=2;i++,putchar('\n'))
for (int j=1;j<=13;j++){
printf("%c",Map[i][j]);
}
return 0;
}