Submission #561397

#TimeUsernameProblemLanguageResultExecution timeMemory
561397Ooops_sorryPalindromes (APIO14_palindrome)C++14
8 / 100
1094 ms131072 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back #define ld long double #define ll long long mt19937 rnd(51); const int INF = 1e9; bool is_palindrome(string s) { return s == (string){s.rbegin(), s.rend()}; } int solve2(string s) { int n = s.size(), ans = -INF; map<string, int> cnt; for (int i = 0; i < n; i++) { for (int j = 1; j + i <= n; j++) { cnt[s.substr(i, j)]++; } } for (int i = 0; i < n; i++) { for (int j = 1; j + i <= n; j++) { if (is_palindrome(s.substr(i, j))) { ans = max(ans, cnt[s.substr(i, j)] * j); } } } return ans; } signed main() { #ifdef LOCAL freopen("input.txt", "r", stdin); #endif // LCOAL ios_base::sync_with_stdio(0); cin.tie(0); string s; cin >> s; cout << solve2(s) << 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...