library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub maspypy/library

:heavy_check_mark: alg/acted_monoid/summax_assign.hpp

Depends on

Verified with

Code

#include "alg/monoid/summax.hpp"

#include "alg/monoid/assign.hpp"


template <typename E, E none_val>
struct ActedMonoid_SumMax_Assign {
  using Monoid_X = Monoid_SumMax<E>;
  using Monoid_A = Monoid_Assign<E, none_val>;
  using X = typename Monoid_X::value_type;
  using A = typename Monoid_A::value_type;
  static constexpr X act(const X& x, const A& a, const ll& size) {
    if (a == Monoid_A::unit()) return x;
    return {E(size) * a, a};
  }
};
#line 2 "alg/monoid/summax.hpp"

template <typename E>
struct Monoid_SumMax {
  using value_type = pair<E, E>;
  using X = value_type;
  static X op(X x, X y) { return {x.fi + y.fi, max(x.se, y.se)}; }
  static X from_element(E e) { return {e, e}; }
  static constexpr X unit() { return {E(0), -infty<E>}; }
  static constexpr bool commute = 1;
};
#line 2 "alg/monoid/assign.hpp"

template <typename X, int none_val>
struct Monoid_Assign {
  using value_type = X;
  static X op(X x, X y) { return (y == X(none_val) ? x : y); }
  static constexpr X unit() { return X(none_val); }
  static constexpr bool commute = false;
};
#line 3 "alg/acted_monoid/summax_assign.hpp"

template <typename E, E none_val>
struct ActedMonoid_SumMax_Assign {
  using Monoid_X = Monoid_SumMax<E>;
  using Monoid_A = Monoid_Assign<E, none_val>;
  using X = typename Monoid_X::value_type;
  using A = typename Monoid_A::value_type;
  static constexpr X act(const X& x, const A& a, const ll& size) {
    if (a == Monoid_A::unit()) return x;
    return {E(size) * a, a};
  }
};
Back to top page