This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/* in the name of allah */
#include<bits/stdc++.h>
using namespace std;
//#define endl '\n'
#define pb push_back
#define F first
#define S second
#define mk make_pair
typedef long long ll;
const ll N=1e6+7,mod=1e13+3,mab=27;
int main(){
ios:: sync_with_stdio(0),cin.tie(0),cout.tie(0);
int q;
cin>>q;
while(q--){
string s;
cin>>s;
ll h1=0,h2=0,t=1;
int j=s.size()-1,sz=s.size();
int ans=0;
for(int h=0;h<=sz/2-1;h++){
//cout<<sz/2-1<<endl;
h1=h1*mab%mod;h1=(h1+s[h]-'a'+1)%mod;
h2=(h2+(s[j-h]-'a'+1)*t)%mod;t=t*mab%mod;
if(h1==h2){
ans+=2;
t=1;h1=0;h2=0;
}
}
if(h1!=0 || s.size()%2==1)ans++;
cout<<ans<<endl;
}
}
# | 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... |