# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1106345 | _callmelucian | Palinilap (COI16_palinilap) | C++14 | 1056 ms | 592 KiB |
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;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tt;
#define all(a) a.begin(), a.end()
#define filter(a) a.erase(unique(all(a)), a.end())
bool palin (const string &s) {
return equal(all(s), s.rbegin());
}
int cost (const string &s) {
int ans = 0;
for (int i = 0; i < s.size(); i++)
for (int j = 1; j <= (int)s.size() - i; j++) ans += palin(s.substr(i, j));
return ans;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
string s; cin >> s;
int n = s.length();
int ans = 0;
for (int i = 0; i < n; i++) {
char c = s[i];
for (int j = 0; j < 26; j++) {
s[i] = char('a' + j);
ans = max(ans, cost(s));
//cout << "change " << i + 1 << " to " << char('a' + j) << " " << cost(s) << "\n";
}
s[i] = c;
}
cout << ans << "\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |