This documentation is automatically generated by online-judge-tools/verification-helper
View the Project on GitHub kmyk/competitive-programming-library
#include "monoids/plus_min_action.hpp"
#pragma once #include "../monoids/plus.hpp" #include "../monoids/min.hpp" template <class T> struct plus_min_action { typename min_monoid<T>::value_type operator () (typename plus_monoid<T>::value_type f, typename min_monoid<T>::value_type x) const { return (x == min_monoid<T>().unit() ? x : f + x); } };
#line 2 "monoids/plus.hpp" template <class T> struct plus_monoid { typedef T value_type; value_type unit() const { return value_type(); } value_type mult(value_type a, value_type b) const { return a + b; } }; #line 2 "monoids/min.hpp" #include <algorithm> #include <limits> template <class T> struct min_monoid { typedef T value_type; value_type unit() const { return std::numeric_limits<T>::max(); } value_type mult(value_type a, value_type b) const { return std::min(a, b); } }; #line 4 "monoids/plus_min_action.hpp" template <class T> struct plus_min_action { typename min_monoid<T>::value_type operator () (typename plus_monoid<T>::value_type f, typename min_monoid<T>::value_type x) const { return (x == min_monoid<T>().unit() ? x : f + x); } };