# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
622671 | enter_hedgehog_poly | Palindromic Partitions (CEOI17_palindromic) | C++11 | 57 ms | 11008 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.
//Palindromiczny podział
#include <bits/stdc++.h>
using namespace std;
char buff[1000010];
typedef uint64_t ll;
const ll P = 31;
const ll MOD_N = 31;
const ll MOD = ((ll) 1 << MOD_N) - 1;
inline ll FMOD(ll x) { return ((x) >> MOD_N) + ((x) & MOD); }
int main() {
int t;
scanf("%d", &t);
while(t--) {
scanf("%s", buff + 1);
int n = strlen(buff + 1);
ll left = 0, right = 0, exp = 1;
int lp = 1, res = 0;
for(int i = 1; i <= n / 2; i++) {
left = FMOD(left + (buff[i] - 'a' + 1) * exp);
exp = FMOD(exp * P);
right = FMOD(right * P + (buff[n + 1 - i] - 'a' + 1));
if(left == right) {
exp = 1;
left = right = 0;
res += 2;
lp = i + 1;
}
}
if(lp != (n / 2) + 1 || (n & 1)) res++;
printf("%d\n", res);
}
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... |