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;
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |