Submission #3861

#TimeUsernameProblemLanguageResultExecution timeMemory
3861cki86201Make superpalindrome! (kriii1_M)C++98
0 / 1
0 ms1672 KiB
#include<stdio.h> #include<string.h> int len; int str[100000]={0}; char s[100001]={0}; char ans[100001]={0}; void f(int a,int b){ if(a==b) return; int i; f(a,(a+b-1)/2); for(i=b;i>(a+b)/2;i--){ str[i]=str[b-i+a]; } } int main() { int i,ch=0; scanf("%s",&s); len=strlen(s); for(i=0;i<len;i++) str[i]=i; f(0,len-1); for(i=0;i<len;i++){ if(i==str[i]) ans[i]=s[i]; } for(i=0;i<len;i++){ if(ans[str[i]]<s[i]){ ans[str[i]]++; ch=1; for(i=str[i]+1;i<len;i++){ if(i==str[i]) ans[str[i]]='a'; } break; } } if(ch==0){ for(i=len-1;i>=0;i--){ if(i==str[i]){ ans[str[i]]++; break; } } } for(i=0;i<len;i++) printf("%c",ans[str[i]]); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...