#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define pii pair<int, int>
#define wr puts("---------------")
#define all(v) v.begin(), v.end()
const int N = 3e5+5;
bool check(deque<char> &dq){
reverse(all(dq));
deque<char> ad = dq;
reverse(all(dq));
return (ad == dq);
}
int weight(string &s){
int ans = 0, n = (int)s.size(), sz = 0;
while(sz != n){
sz++;
deque<char> dq;
for(int i = 0; i < sz; ++i)
dq.pb(s[i]);
ans += (check(dq));
for(int i = sz; i < n; ++i)
dq.pb(s[i]), dq.pop_front(), ans += (check(dq));
}
return ans;
}
int main(){
string s;
cin >> s;
int n = (int)s.size(), answer = 0;
for(int i = 0; i < n; ++i){
string ad = s;
for(char c = 'a'; c <= 'z'; ++c)
ad[i] = c, answer = max(answer, weight(ad)), ad = s;
}
printf("%d", answer);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
987 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
1060 ms |
344 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1063 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1033 ms |
600 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |