This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |