# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
351264 | denkendoemeer | Palindromes (APIO14_palindrome) | C++14 | 31 ms | 39660 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<bits/stdc++.h>
#define ll long long
using namespace std;
int cnt[300005][30],len[300005],nex[300005],cnt2[300005],u;
char s[300005];
int findnex(int nod,int p)
{
while(s[p]!=s[p-len[nod]-1])
nod=nex[nod];
return nod;
}
int update(int nod,int p)
{
int aux=s[p]-97;
nod=findnex(nod,p);
if (cnt[nod][aux]==0){
++u;
len[u]=len[nod]+2;
nex[u]=cnt[findnex(nex[nod],p)][aux];
cnt[nod][aux]=u;
}
return cnt[nod][aux];
}
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
fgets(s,300003,stdin);
int n=strlen(s)-1;
len[1]=-1;
u=1;
nex[0]=nex[1]=1;
int cur=1,i;
for(i=0;i<n;i++)
cur=update(cur,i),cnt2[cur]++;
ll ans=0;
for(i=u;i>=0;i--)
cnt2[nex[i]]=cnt2[nex[i]]+cnt2[i],ans=max(ans,1LL*cnt2[i]*len[i]);
printf("%lld\n",ans);
return 0;
}
Compilation message (stderr)
# | 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... |