#include <bits/stdc++.h>
using namespace std;
const int64_t mod = (srand(time(0)), (int64_t(rand()) << 29) + rand());
constexpr int B = 29;
void solve() {
string s;
cin >> s;
int64_t hf = 0, hb = 0, pow = 1;
int c = 0;
#pragma GCC ivdep
for (char &c : s) c -= 96;
for (int i = 0; i < s.size() >> 1; i++) {
hf = (hf * B % mod + s[i]) % mod;
hb = (hb + pow * s[s.size() - i - 1] % mod) % mod;
pow = pow * B % mod;
if (hf == hb) {
++c;
hf = hb = 0;
pow = 1;
}
}
cout << 2 * c + (s.size() & 1 || hf) << '\n';
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.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... |