#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 100007;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
const double eps = 1e-6;
const int dx[] = {0, -1, 0, 1}, dy[] = {1, 0, -1, 0};
const int block = 320;
string s;
int cnt[M][30], ans;
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> s;
int n = s.size(); s = '#' + s;
for(int mid = 1; mid <= n; ++mid){
int l = mid, r = mid;
int pos1 = 0, pos2 = 0, c1 = 0, c2 = 0;
while(l && r <= n){
if(s[l] != s[r]){
if(pos1) break;
pos1 = l;
pos2 = r;
c1 = s[r] - 'a';
c2 = s[l] - 'a';
}
++cnt[pos1][c1];
++cnt[pos2][c2];
if(pos1 == 0) ++ans;
--l; ++r;
}
l = mid, r = mid + 1;
pos1 = 0; pos2 = 0; c1 = 0; c2 = 0;
while(l && r <= n){
if(s[l] != s[r]){
if(pos1) break;
pos1 = l;
pos2 = r;
c1 = s[r] - 'a';
c2 = s[l] - 'a';
}
++cnt[pos1][c1];
++cnt[pos2][c2];
if(pos1 == 0) ++ans;
--l; ++r;
}
}
int mx = 0;
for(int i = 1; i <+ n; ++i) for(int j = 0; j < 26; ++j) mx = max(mx, cnt[i][j]);
cout << ans + mx << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
912 KB |
Output is correct |
2 |
Incorrect |
60 ms |
860 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
12368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |