# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
122927 | davitmarg | Palindromic Partitions (CEOI17_palindromic) | C++17 | 58 ms | 11156 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.
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <bitset>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <ctype.h>
#include <stdlib.h>
#include <cassert>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
#define FIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int t;
string s;
LL h1,h2,p=351,a=1;
int main()
{
FIO;
cin>>t;
while(t--)
{
cin>>s;
int ans=0;
for(int i=0;i<s.length();i++)
{
h1+=a*(s[i]-'a'+1);
h2*=p;
h2+=s[s.length()-1-i]-'a'+1;
a*=p;
if(h1==h2)
{
a=1;
h1=h2=0;
ans++;
}
}
cout<<ans<<endl;
}
return 0;
}
/*
4 4 1
1 2
2 3
*/
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... |