# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
670375 | Mohammad_Parsa | Palindromic Partitions (CEOI17_palindromic) | C++17 | 0 ms | 212 KiB |
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;
int ans=0;
for(int h=0;h<=s.size()/2-1;h++){
h1=h1*mab%mod;h1=(h1+s[h]-'a')%mod;
h2=(h2+(s[j-h]-'a')*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;
}
}
Compilation message (stderr)
# | 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... |