Submission #157329

#TimeUsernameProblemLanguageResultExecution timeMemory
157329likhon5Palindromes (APIO14_palindrome)C++14
0 / 100
101 ms69140 KiB
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll mx=300009;
ll nxt[mx][26];
ll len[mx],link[mx];
ll node,t;
string str;
void pre()
{
    len[1]=-1,len[2]=0;
    link[1]=link[2]=1;
    node=t=2;
}
ll cal[mx];
void add(ll p)
{
    while(str[p-len[t]-1]!=str[p]) t=link[t];
    ll x=link[t];
    while(str[p-len[x]-1]!=str[p]) x=link[x];
    ll c=str[p]-'a';
    if(nxt[t][c]==false)
    {
        nxt[t][c]=++node;
        len[node]=len[t]+2;
        link[node]=(len[node]==1)? 2: nxt[x][c];
    }
    t=nxt[t][c] ;
    cal[node]++;
}
int   main()
{
    cin>>str;
    pre();
    for(ll i=0;i<(int)str.size();i++) add(i);
    for(ll i=node;i>=3;i--)  cal[link[i]]+=cal[i];
    ll ans=-1;
    for(ll i=3;i<=node;i++)
    {
        ans=max(ans,len[i]*cal[i]);
    }
    cout<<ans<<endl;
}
#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...