Submission #3861

# Submission time Handle Problem Language Result Execution time Memory
3861 2013-08-31T08:55:38 Z cki86201 Make superpalindrome! (kriii1_M) C++
0 / 1
0 ms 1672 KB
#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 time Memory Grader output
1 Incorrect 0 ms 1672 KB Output isn't correct
2 Halted 0 ms 0 KB -