# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
545914 | rainboy | Palindromic Partitions (CEOI17_palindromic) | C11 | 139 ms | 16748 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 <stdio.h>
#include <string.h>
#define N 1000000
int main() {
int t;
scanf("%d", &t);
while (t--) {
static char cc[N + 1], cc_[N * 2 + 2];
static int rr[N * 2 + 1];
int n, i, j, o, x, ans;
scanf("%s", cc), n = strlen(cc);
for (i = 0; i <= n * 2; i++)
cc_[i] = i % 2 == 0 ? ' ' : (i / 2 % 2 == 0 ? cc[i / 4] : cc[n - 1 - i / 4]);
cc_[n * 2 + 1] = 0;
for (i = 0, o = x = 0; i <= n * 2; i++)
if (o + o - i >= 0 && i + rr[o + o - i] < x)
rr[i] = rr[o + o - i];
else {
o = i;
while (x <= n * 2 && o + o - x >= 0 && cc_[x] == cc_[o + o - x])
x++;
rr[i] = x - o;
}
ans = 0;
for (i = 0, j = 2; j <= n; j += 2)
if (rr[i + j] > j - i)
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... |