#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
void solve(){
string s;
cin >> s;
int res = 0;
int l = 0, r = s.size();
r--;
string a, b;
while(l < r){
a.push_back(s[l]);
reverse(b.begin(), b.end());
b.push_back(s[r]);
reverse(b.begin(), b.end());
if(a == b){
a.clear();
b.clear();
res += 2;
}
l++;
r--;
}
if(a.empty() and l != r){
cout << res << endl;
}
else cout << res+1 << endl;
}
int main(){
ios::sync_with_stdio(false); cin.tie(0);
int t;
cin >> t;
while(t--){
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |