56 std::cout << std::setw(14) << std::left << label <<
": [";
57 for (
size_t i = 0; i < arr.
size(); ++i)
75 template <
typename Fn>
82 std::cout << label <<
"\n";
87 std::cout << std::setw(14) << std::left <<
len_label <<
": " <<
r.length <<
"\n";
103 std::cout <<
"\n=== Longest Increasing Subsequence Toolkit ===\n\n";
107 Array<int> seq = {10, 9, 2, 5, 3, 7, 101, 18};
110 "One LIS",
"LIS length");
111 std::cout << std::setw(14) << std::left <<
"Length-only" <<
": "
122 "One LIS",
"LIS length");
132 "One LIS",
"LIS length");
140 run_scenario(
"Scenario D: Longest non-decreasing subsequence", seq,
142 "One LNDS",
"LNDS length");
149 std::cout <<
"Scenario E: Decreasing subsequence via comparator\n";
158 std::cout << std::setw(14) << std::left <<
"LDS length" <<
": "
159 <<
lds.length <<
"\n";
160 std::cout << std::setw(14) << std::left <<
"Non-inc len" <<
": "
165 std::cout <<
"\nDone.\n";
Longest Increasing Subsequence (LIS) via patience sorting.
Simple dynamic array with automatic resizing and functional operations.
constexpr size_t size() const noexcept
Return the number of elements stored in the stack.
int main()
Demonstrates usage of Aleph-w LIS/LNDS utilities by running several example scenarios and printing th...
Main namespace for Aleph-w library functions.
LIS_Result< T > longest_nondecreasing_subsequence(const Array< T > &seq, Compare cmp=Compare())
Compute the Longest Non-Decreasing Subsequence.
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.
LIS_Result< T > longest_increasing_subsequence(const Array< T > &seq, Compare cmp=Compare())
Compute the Longest Increasing Subsequence (patience sorting).
void print_rule()
Prints a horizontal rule for example output separation.
size_t lis_length(const Array< T > &seq, Compare cmp=Compare())
Compute only the length of the LIS (no reconstruction).
void print_array(const char *label, const Container &a)