#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int N=1e6+5,tt=10,mod=1e9+7;
int pw[N];
signed main(){
pw[0]=1;
for(int i=1;i<N;i++)pw[i]=pw[i-1]*tt%mod;
int t;
cin>>t;
while(t--){
string s;
cin>>s;
int l=0,r=s.size()-1;
int sz=0,x=0,y=0,res=0;
while(l<r){
sz++;
x+=pw[sz]*s[l]%mod;
y*=tt%mod;
y+=s[r]*tt%mod;
if(x==y){
res+=2;
x=0;y=0;sz=0;
}
l++;r--;
}
if(l==r)sz++;
if(sz)res++;
cout<<res<<"\n";
}
}
/*
4
bonobo
deleted
racecar
racecars
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
8028 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
8028 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
8028 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
8028 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |