Submission #897623

#TimeUsernameProblemLanguageResultExecution timeMemory
897623AndrijaMPalindromes (APIO14_palindrome)C++14
8 / 100
1069 ms2092 KiB
#include <bits/stdc++.h> using namespace std; const long long maxn=1e4+10; const long long mod=1e9+7; int main() { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); string s; long long ans=0LL; cin>>s; int n=s.size(); map<deque<char>,int>m; for(int i=0;i<n;i++) { deque<char>Q; int l=i; int r=i; Q.push_front(s[i]); m[Q]++; while(l-1>=0 && r+1<n) { if(s[l-1]==s[r+1]) { l--; r++; Q.push_front(s[l]); Q.push_back(s[r]); m[Q]++; } else { break; } } } for(auto ax:m) { long long num=ax.first.size()*ax.second; ans=max(num,ans); } m.clear(); for(int i=0;i<n-1;i++) { deque<char>Q; int l=i; int r=i+1; if(s[l]!=s[r])continue; Q.push_front(s[l]); Q.push_back(s[r]); m[Q]++; while(l-1>=0 && r+1<n) { if(s[l-1]==s[r+1]) { l--; r++; Q.push_front(s[l]); Q.push_back(s[r]); m[Q]++; } else { break; } } } for(auto ax:m) { long long num=ax.first.size()*ax.second; ans=max(num,ans); } cout<<ans<<endl; return 0; }
#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...