이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<stdio.h>
#include<string.h>
#include<algorithm>
int n;
char a[300100];
int b[600100];
int q[30][300100];
int qe[30];
int grp[600100];
int grd[600100];
int ngrp[600100];
int ngrd[600100];
int grn;
int grk;
int ans;
int main(){
int i,j,k,pn;
scanf("%s",a);
n=strlen(a);
for(i=0;i<n;i++){
b[2*i+2]=a[i]-'a'+1;
}
b[0]=27;
b[2*n+2]=28;
n=2*n+3;
for(i=0;i<n;i++){
grd[i]=i;
}
grn=n;
for(i=0;grn;i++){
for(j=0;j<29;j++){
qe[j]=0;
}
for(j=0;j<grn;j++){
if(b[grd[j]-i]==b[grd[j]+i]){
k=b[grd[j]-i];
q[k][qe[k]]=j;
qe[k]++;
}
}
grn=0;
grk=0;
for(j=0;j<29;j++){
pn=0;
for(k=0;k<qe[j];k++){
ngrp[grn]=grk;
ngrd[grn]=grd[q[j][k]];
grn++;
pn++;
if(k+1==qe[j]||grp[q[j][k]]!=grp[q[j][k+1]]){
if(ans<pn*i)ans=pn*i;
pn=0;
grk++;
}
}
}
for(j=0;j<grn;j++){
grd[j]=ngrd[j];
grp[j]=ngrp[j];
}
}
printf("%d",ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |