#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...) 47
#endif
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) {
ans += 2;
pre.clear();
suf.clear();
}
}
if (l <= r || !pre.empty()) {
ans++;
}
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... |