#include <stdio.h>
#include <string.h>
char S[100010],P[100010];
int Ck[20];
int N,M,F;
void Copying(int n)
{
int w;
w=(n%2==1)?n/2+1:n/2;
if(n==1)return;
else {
Copying(n/2);
for(int i=0;i<n/2;i++)P[w+i]=P[i];
}
}
void Palindrome(int n)
{
int i;
if(F==1)return;
if(n>M){
Copying(N);
if(strcmp(P,S)>0){
F=1;
printf("%s\n",P);
}
return;
}
for(i=0;i<26;i++){
P[Ck[n]/2]='a'+i;
Palindrome(n+1);
}
}
int main()
{
int i,n;
scanf("%s",S);
n=N=strlen(S);
while(n>1){
if(n%2==1)Ck[++M]=n;
n/=2;
}
P[0]=S[0];
Palindrome(1);
if(F==0){
P[0]=S[0]+1;
Palindrome(1);
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1284 KB |
Output is correct |
2 |
Execution timed out |
200 ms |
1280 KB |
Program timed out |
3 |
Halted |
0 ms |
0 KB |
- |