# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3747 | jihoon | Make superpalindrome! (kriii1_M) | C++98 | 0 ms | 1672 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
#include<string.h>
char str[100003]={0};
char sv[100003]={0};
int len;
int seq[50001][2]={0};
int seqp=0;
int bs(int s,int e){
int i;
int mid=(s+e)/2;
if(s>e) return 0;
if((e-s)%2==0){
seqp++;
seq[seqp][0]=str[mid];
sv[mid]=str[mid];
seq[seqp][1]=mid;
// printf("%c\n",str[mid]);
}
bs(s,mid-1+((e-s)%2));
for(i=s;i<=mid;i++){
sv[s+e-i]=sv[i];
}
//printf("%s\n",sv);
return 0;
}
int main(){
int i;
bool dd=false;
int svv;
scanf("%s",str);
len=(int)strlen(str);
bs(0,len-1);
svv=len-1;
/*
for(i=0;i<len;i++){
printf("%c",sv[i]);
}
printf("\n");
*/
for(i=0;i<len;i++){
if(str[i]>sv[i]){
svv=i;
break;
}else if(str[i]<sv[i]){
dd=true;
break;
}
}
if(dd){
printf("%s",sv);
}else{
for(i=1;i<=seqp;i++){
seq[i][0]-=97;
}
for(i=1;i<=seqp;i++){
if(seq[i][1]<=svv){
seq[i][0]++;
// printf("%d\n",i);
break;
}
}
for(i=1;i<=seqp;i++){
seq[i+1][0]+=(seq[i][0]/26);
seq[i][0]=seq[i][0]%26;
}
for(i=1;i<=seqp;i++){
seq[i][0]+=97;
str[seq[i][1]]=seq[i][0];
}
// printf("%s\n",str);
bs(0,len-1);
printf("%s",sv);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |