Submission #900043

#TimeUsernameProblemLanguageResultExecution timeMemory
9000431075508020060209tcPalindromes (APIO14_palindrome)C++14
0 / 100
1045 ms28100 KiB
#pragma GCC optimize("O3") #include<bits/stdc++.h> using namespace std; #define int long long #define X first #define Y second #define SZ(x) (int)(x).size() const int mod=1e9+7; int qpow(int x,int t){ if(t==0){return 1;} if(t%2==1){return qpow(x,t-1)*x%mod;} int xx=qpow(x,t/2); return xx*xx%mod; } int tme[500005]; struct rlhsh{ vector<int>hsh; int n; void init(string s){ n=s.size(); hsh.resize(s.size()+10,0); for(int i=1;i<=n;i++){ hsh[i]=(hsh[i-1]+(s[i-1]-'a')*tme[i])%mod; } } int gthsh(int l,int r){ int ret=(hsh[r]-hsh[l-1]+mod)*qpow(tme[l-1],mod-2)%mod; return ret; } }; int n; pair<int,int>rev(int l,int r){ l=n-l+1;r=n-r+1; swap(l,r); return {l,r}; } string s; signed main(){ tme[0]=1; for(int i=1;i<=500000;i++){ tme[i]=tme[i-1]*37%mod; } cin>>s; n=s.size(); rlhsh sh; sh.init(s); reverse(s.begin(),s.end()); rlhsh rsh; rsh.init(s); int ans=1; map<int,int>mp; for(int i=1;i<=n;i++){ for(int j=i;j<=n;j++){ int v=sh.gthsh(i,j); if(v==rsh.gthsh(n-j+1,n-i+1)){ mp[v]++; ans=max(ans,mp[v]*(j-i+1)); } } } 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...