Submission #582042

#TimeUsernameProblemLanguageResultExecution timeMemory
582042l_rehoPalindromes (APIO14_palindrome)C++14
23 / 100
117 ms3708 KiB
#include<bits/stdc++.h> using namespace std; #define x first #define y second #define ll long long string S; bool dp[1005][1005]; map<string, int> mp; void solve(){ ifstream in("input.txt"); ofstream out("output.txt"); cin>>S; int N = S.length(); for(int i = 0; i < N; i++){ dp[i][i] = 1; mp[S.substr(i, 1)]++; } for(int i = 0; i < N-1; i++){ if(S[i] == S[i+1]){ dp[i][i+1] = 1; mp[S.substr(i, 2)]++; } } for(int i = 3; i <= N; i++){ for(int j = 0; j <= N-i; j++){ int end = j+i-1; if(dp[j+1][end-1] && S[j] == S[end]){ dp[j][end] = 1; mp[S.substr(j, i)]++; } } } int ans = 0; for(auto a : mp){ ans = max(ans, (int)(a.first.length())*a.second); } cout<<ans<<endl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); }
#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...