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;
using ll = long long;
signed main() {
cin.tie(0)->sync_with_stdio(0);
string s;
cin >> s;
int n = s.size();
ll ans = 0;
map<string, int> mp;
for (int l = 0; l < n; l++) {
for (int r = l; r < n; r++) {
string t = s.substr(l, r - l + 1);
mp[t]++;
string rev = t;
reverse(rev.begin(), rev.end());
bool ispal = t == rev;
if (ispal) {
ans = max(ans, (ll)(r - l + 1) * mp[t]);
}
}
}
cout << ans << '\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... |