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