| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 3842 | shinhj88 | Make superpalindrome! (kriii1_M) | C++98 | 200 ms | 1284 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
|---|---|---|---|---|
| Fetching results... | ||||
