# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
35493 | imaxblue | Palindromic Partitions (CEOI17_palindromic) | C++14 | 403 ms | 12792 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.
#include <iostream>
using namespace std;
const int seed=1337, mod=1000000007;
string s;
int t, x, p, c, y;
int fwh[1000005], bwh[1000005];
int main() {
cin >> t;
for (int l=0; l<t; ++l){
cin >> s;
x=0; y=0; p=1; c=1;
for (int l=0; l<s.size()/2; ++l){
x=(1LL*x*seed)%mod+s[l]-'a'+1;
y=(y+(1LL*p*(s[s.size()-l-1]-'a'+1)))%mod;
p=(1LL*p*seed)%mod;
if (x==y){
//cout << l << ' ';
c+=2;
x=0; y=0; p=1;
if ((l+1)*2==s.size()) c--;
}
}
//for (int l=0; l<s.size(); ++l) cout << fwh[l] << ' ' ; cout << endl;
//for (int l=0; l<s.size(); ++l) cout << bwh[l] << ' ' ; cout << endl;
cout << c << endl;
}
return 0;
}
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... |