37# include <gtest/gtest.h>
97 std::string
half =
"abcdefghijklmnopqrstuvwxyz";
109 const auto r =
manacher(
"xxxracecarxxx");
110 EXPECT_EQ(
r.longest_palindrome,
"xxxracecarxxx");
117 const std::string text(1000,
'z');
184 const std::string text =
"abcbaXcbcYaabaa";
185 const size_t n = text.size();
192 for (
size_t i = 0; i < n; ++i)
195 while (i >=
k and i +
k < n
and text[i -
k] == text[i +
k])
197 EXPECT_EQ(
r.odd_radius[i],
k) <<
"odd_radius mismatch at i=" << i;
201 for (
size_t i = 0; i < n; ++i)
204 while (i >=
k + 1
and i +
k < n
and text[i -
k - 1] == text[i +
k])
206 EXPECT_EQ(
r.even_radius[i],
k) <<
"even_radius mismatch at i=" << i;
244 for (
int i = 0; i < 2000; ++i)
245 text.push_back(
'a' + (i * 7 + 3) % 4);
247 const size_t n = text.size();
253 for (
size_t i = 0; i < n; ++i)
256 while (i >=
k and i +
k < n
and text[i -
k] == text[i +
k])
261 for (
size_t i = 0; i < n; ++i)
264 while (i >=
k + 1
and i +
k < n
and text[i -
k - 1] == text[i +
k])
Palindrome algorithms over strings.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Main namespace for Aleph-w library functions.
and
Check uniqueness with explicit hash + equality functors.
std::string longest_palindromic_substring(const std::string_view text)
Convenience wrapper returning only the longest palindromic substring.
Manacher_Result manacher(const std::string_view text)
Compute palindromic radii and the longest palindrome with Manacher.