Submission #926507

# Submission time Handle Problem Language Result Execution time Memory
926507 2024-02-13T07:33:45 Z vjudge1 Palindromes (APIO14_palindrome) C++17
0 / 100
1000 ms 9180 KB
#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-1]=c;
        while (S[sz-2-len[p]]-S[sz-1])p=li[p];
        if (!t[p][c]) {
            len[t[p][c]=++sz]=len[p]+2;
            do p=li[p];while(S[sz-len[p]-2]-S[sz-1]);
            li[sz] = t[p][c];
        }
        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 time Memory Grader output
1 Execution timed out 1039 ms 9052 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 9052 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1046 ms 9180 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 9052 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1035 ms 9048 KB Time limit exceeded
2 Halted 0 ms 0 KB -