Submission #1106345

#TimeUsernameProblemLanguageResultExecution timeMemory
1106345_callmelucianPalinilap (COI16_palinilap)C++14
17 / 100
1056 ms592 KiB
#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)

palinilap.cpp: In function 'int cost(const string&)':
palinilap.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i = 0; i < s.size(); i++)
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...