Submission #958981

#TimeUsernameProblemLanguageResultExecution timeMemory
958981KasymKPalindromes (APIO14_palindrome)C++17
8 / 100
1060 ms1480 KiB
#include <bits/stdc++.h> using namespace std; bool pal(string a) { int l = 0, r = a.size() - 1; while (l < r) { if (a[l] != a[r]) return false; l++, r--; } return true; } int occ(string a, string ss) { int n = (int)ss.size(); int k = (int)a.size(); int cnt = 0, gec = 0; while (cnt != n - k + 1) { if (ss.substr(cnt, k) == a) gec++; cnt++; } return gec; } int main() { string ss; cin >> ss; int n = (int)ss.size(); int mx = INT_MIN; for (int i = 0; i < n; ++i) for (int j = 1; j <= n - i; ++j) { string a = ss.substr(i, j); if (pal(a)) { int ret = a.size() * occ(a, ss); mx = max(mx, ret); } } cout << mx << "\n"; 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...