Submission #926518

#TimeUsernameProblemLanguageResultExecution timeMemory
926518vjudge1Palindromes (APIO14_palindrome)C++17
0 / 100
26 ms70904 KiB
#include<bits/stdc++.h>
#define N 300100
using namespace std;
long long S[N],ans,c;
struct T {
    long long t[N][26],li[N],len[N],oc[N],sz,lst;
    T(){sz=li[0]=li[1]=1;len[1]=-1;}
    void add(int c) {
        int p = lst;S[sz]=c;
        while (S[sz-1-len[p]]-c)p=li[p];
        if (!t[p][c]) {
            int q=li[p];
            while(S[sz-len[q]-1]-c)q=li[q];
            li[++sz]=t[q][c];
            len[t[p][c]=sz]=len[p]+2;
        }
        oc[lst=t[p][c]]++;
    }
} X; 
int main() {
    memset(S,1,sizeof S);
    c=getchar();
    while(c!='\n') X.add(c-'a'),c=getchar();
    for(int x=X.sz;~x;x--)
        X.oc[X.li[x]]+=X.oc[x];
    for(int x=X.sz;~x;x--)
        ans=max(ans,X.len[x]*X.oc[x]);
    cout<<ans<<'\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...