# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
915843 | vjudge1 | Palindromic Partitions (CEOI17_palindromic) | C++17 | 157 ms | 3540 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <cassert>
#define MAX_WORD_LENGTH 5100000
int longest_palindromic_partition(const std::string& word) {
const int n = word.length();
const unsigned int base = 131;
int done_chars = 0;
int n_chunks = 0;
while (done_chars * 2 < n) {
unsigned int left_hash = 0, right_hash = 0;
unsigned int base_power = 1;
for (int chunk_size = 1; true; chunk_size++) {
const int l = done_chars;
const int r = n - done_chars - chunk_size;
if (l + chunk_size - 1 >= r) {
return n_chunks + 1;
}
base_power = (chunk_size == 1) ? 1 : base_power * base;
left_hash += static_cast<unsigned int>(word[l + chunk_size - 1]) * base_power;
right_hash = static_cast<unsigned int>(word[r]) + right_hash * base;
if (left_hash == right_hash && word.compare(l, chunk_size, word, r, chunk_size) == 0) {
n_chunks += 2;
done_chars += chunk_size;
# | 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... |