Submission #990724

#TimeUsernameProblemLanguageResultExecution timeMemory
990724vjudge1Palinilap (COI16_palinilap)C++17
17 / 100
1074 ms856 KiB
#include<bits/stdc++.h> using namespace std; int w(string s) { int ans = 0, n = s.size(); for(int i = 0; i < n; i ++) { int cnt = 1; int l = i - 1, r = i + 1; while(l >= 0 && r < n) { if(s[l] == s[r]) cnt++, l--, r++; else break; } ans += cnt; } for(int i = 0; i + 1 < n; i ++) { if(s[i] != s[i + 1]) continue; int cnt = 1; int l = i - 1, r = i + 2; while(l >= 0 && r < n) { if(s[l] == s[r]) cnt++, l--, r++; else break; } ans += cnt; } return ans; } int main() { int ans = 0, n; string s; cin >> s; n = s.size(); ans = w(s); for(int i = 0; i < n; i ++) { char c = s[i]; for(char nc = 'a'; nc <= 'z'; nc ++) { if(c == nc) continue; s[i] = nc; ans = max(ans, w(s)); } s[i] = c; } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...