# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
545914 | 2022-04-05T16:08:59 Z | rainboy | Palindromic Partitions (CEOI17_palindromic) | C | 139 ms | 16748 KB |
#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) i = j, ans += 2; if (i < n) ans++; printf("%d\n", ans); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 292 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 296 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 292 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 296 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 292 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 296 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 2 ms | 468 KB | Output is correct |
11 | Correct | 2 ms | 468 KB | Output is correct |
12 | Correct | 2 ms | 468 KB | Output is correct |
13 | Correct | 2 ms | 468 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 292 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 296 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 2 ms | 468 KB | Output is correct |
11 | Correct | 2 ms | 468 KB | Output is correct |
12 | Correct | 2 ms | 468 KB | Output is correct |
13 | Correct | 2 ms | 468 KB | Output is correct |
14 | Correct | 130 ms | 16652 KB | Output is correct |
15 | Correct | 71 ms | 16132 KB | Output is correct |
16 | Correct | 139 ms | 16748 KB | Output is correct |
17 | Correct | 73 ms | 11040 KB | Output is correct |