ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
HouseProblems.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*-------------------------- File HouseProblems.h --------------------------*/
3/*--------------------------------------------------------------------------*/
48/*--------------------------------------------------------------------------*/
49/*----------------------------- DEFINITIONS --------------------------------*/
50/*--------------------------------------------------------------------------*/
51
52#ifndef __ADS_HouseProblems
53 #define __ADS_HouseProblems
54/* self-identification: #endif constant */
55
56/*--------------------------------------------------------------------------*/
57/*------------------------------ INCLUDES ----------------------------------*/
58/*--------------------------------------------------------------------------*/
59
60#include "ADS/Contract.h"
61
62#include <algorithm>
63#include <cstddef>
64#include <utility>
65#include <vector>
66
67/*--------------------------------------------------------------------------*/
68/*--------------------------- NAMESPACE ------------------------------------*/
69/*--------------------------------------------------------------------------*/
70
71namespace ADS
72{
73
92template< class T >
93T maxNonAdjacentSum( const std::vector< T > & A );
94
116template< class T >
117std::pair< T , std::vector< std::size_t > >
118nonAdjacentSelection( const std::vector< T > & A );
119
149template< class T >
150std::pair< T , std::vector< std::size_t > >
151paintHouses( const std::vector< std::vector< T > > & cost );
152
153/*--------------------------------------------------------------------------*/
154
155} // end( namespace ADS )
156
157/*--------------------------------------------------------------------------*/
158/*-------------------------- IMPLEMENTATION --------------------------------*/
159/*--------------------------------------------------------------------------*/
160
161#include "ADS/optimization/impl/HouseProblems.tpp"
162
163/*--------------------------------------------------------------------------*/
164
165#endif /* HouseProblems.h included */
166
167/*--------------------------------------------------------------------------*/
168/*------------------------ End File HouseProblems.h ------------------------*/
169/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
T maxNonAdjacentSum(const std::vector< T > &A)
the largest sum of items of no two of them adjacent, 0 for none
std::pair< T, std::vector< std::size_t > > nonAdjacentSelection(const std::vector< T > &A)
the sum of maxNonAdjacentSum() and the places of its items, increasing; an item is taken only if it m...
std::pair< T, std::vector< std::size_t > > paintHouses(const std::vector< std::vector< T > > &cost)
the least cost of a painting of the houses, adjacent houses of different colors, for the house of t...
Definition ADT.h:96