Submission #926558

#TimeUsernameProblemLanguageResultExecution timeMemory
926558boyliguanhanPalindromes (APIO14_palindrome)C++17
100 / 100
39 ms70876 KiB
#include<bits/stdc++.h> #define N 300100 using namespace std; long long S[N],ans,c,m; 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[++m]=c; while (S[m-1-len[p]]-c)p=li[p]; if (!t[p][c]) { int q=li[p]; while(S[m-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...