This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll t,n,p=31;
string s;
cin >> t;
while (t--)
{
cin >> s;
n=s.size();
s=' '+s;
ll ans=0,l=1,r=n,curl=0,curr=0,d=1;
while (true)
{
if (l>=r)
{
ans++;
break;
}
curl=(curl+(s[l]-'a'+1)*d)%MOD;
d=(d*p)%MOD;
curr=(curr*p+s[r]-'a'+1)%MOD;
if (curl==curr)
{
ans+=2;
d=1;
curl=curr=0;
}
l++;
r--;
}
cout << ans << "\n";
}
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... |