#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
6 ms |
436 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1074 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1024 ms |
856 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |