# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
156886 | junodeveloper | Palindromic Partitions (CEOI17_palindromic) | C++14 | 77 ms | 11052 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 <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=(ll)1e17-3;
int t,n;
char s[1000010];
int main() {
scanf("%d",&t);
int i,j;
while(t--) {
scanf("%s",s);
n=strlen(s);
j=n;
ll hl=0,hr=0,pw=1,cnt=0;
for(i=0;i<n/2;i++) {
hl=(26*hl+s[i]-'a')%mod;
hr=(hr+(s[n-i-1]-'a')*pw%mod)%mod;
if(hl==hr) {
cnt+=2;
j=i;
hl=hr=0; pw=1;
} else pw=26*pw%mod;
}
if(n%2||j!=n/2-1) cnt++;
printf("%lld\n",cnt);
}
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... |