Submission #712974

#TimeUsernameProblemLanguageResultExecution timeMemory
712974bin9638Palindromes (APIO14_palindrome)C++17
23 / 100
1066 ms988 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define N 1000010 #define ii pair<int,int> #define fs first #define sc second #define ld double string s; int n; map<string,int>mp; bool check_palin(int l,int r) { for(int i=1;i*2<=(r-l+1);i++) if(s[l+i-1]!=s[r-i+1]) return 0; return 1; } int solve(int k) { int cnt=0; mp.clear(); for(int i=1;i<=n-k+1;i++) if(check_palin(i,i+k-1)) cnt=max(cnt,++mp[s.substr(i,k)]); return cnt*k; } int main() { #ifdef SKY freopen("A.inp","r",stdin); freopen("A.out","w",stdout); #endif // SKY ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin>>s; n=s.size(); s=" "+s; int res=0; for(int i=1;i<=n;i++) { int val=solve(i); res=max(res,val); } cout<<res; }
#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...