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;
#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 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... |