37# include <gtest/gtest.h>
48using namespace testing;
54 int operator()(
const int a,
const int b)
const noexcept
56 return std::gcd(a, b);
60 template <
typename T,
class Op>
62 const size_t l,
const size_t r, Op op)
65 for (
size_t i =
l + 1; i <=
r; ++i)
92 for (
size_t i = 0; i < st.
size(); ++i)
98 const std::vector<int> values = {9, 4, 7, 1, 8, 2, 6, 3, 5, 0};
102 for (
size_t l = 0;
l < values.
size(); ++
l)
103 for (
size_t r =
l;
r < values.
size(); ++
r)
105 const int expected_min = *std::min_element(values.begin() +
l,
107 const int expected_max = *std::max_element(values.begin() +
l,
116 const std::vector<int> values = {5, 3, 7, 1, 9, 2, 8, 4, 6};
120 for (
const int x : values)
125 for (
const int x : values)
131 for (
size_t l = 0;
l < values.
size(); ++
l)
132 for (
size_t r =
l;
r < values.
size(); ++
r)
134 const int expected = *std::min_element(values.begin() +
l,
145 const std::vector<int> values = {12, 18, 24, 36, 60, 48, 30, 90, 15, 45};
148 for (
size_t l = 0;
l < values.
size(); ++
l)
149 for (
size_t r =
l;
r < values.
size(); ++
r)
155 const std::vector<int> base = {8, 6, 7, 5, 3, 0, 9};
160 for (
size_t i = 0; i < base.size(); ++i)
Simple dynamic array with automatic resizing and functional operations.
T & append(const T &data)
Append a copy of data
Dynamic singly linked list with functional programming support.
T & append(const T &item)
Sparse Table over an arbitrary associative and idempotent binary operation.
T get(const size_t i) const
Retrieve the value a[i] in O(1).
Array< T > values() const
Reconstruct all original values into an Array.
constexpr size_t size() const noexcept
Number of logical elements.
constexpr bool is_empty() const noexcept
True if the table contains no elements.
T query(const size_t l, const size_t r) const
Range query over [l, r] in O(1).
void swap(Gen_Sparse_Table &other) noexcept
Swap this table with other in O(1).
size_t size() const noexcept
Count the number of elements of the list.
iterator begin() noexcept
Return an STL-compatible iterator to the first element.
Main namespace for Aleph-w library functions.
Itor2 copy(Itor1 sourceBeg, const Itor1 &sourceEnd, Itor2 destBeg)
Copy elements from one range to another.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
std::decay_t< typename HeadC::Item_Type > T
Sparse Table for range maximum queries.
Sparse Table for range minimum queries.
int operator()(const int &a, const int &b) const noexcept
Sparse Table for static range queries in O(1).