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/minmax_add.hpp

Depends on

Verified with

Code

#include "alg/monoid/add.hpp"

#include "alg/monoid/minmax.hpp"


template <typename E>
struct ActedMonoid_MinMax_Add {
  using Monoid_X = Monoid_MinMax<E>;
  using Monoid_A = Monoid_Add<E>;
  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) {
    E lo = (x.fi == infty<E> ? x.fi : x.fi + a);
    E hi = (x.se == -infty<E> ? x.se : x.se + a);
    return {lo, hi};
  }
};
#line 2 "alg/monoid/add.hpp"

template <typename E>
struct Monoid_Add {
  using X = E;
  using value_type = X;
  static constexpr X op(const X &x, const X &y) noexcept { return x + y; }
  static constexpr X inverse(const X &x) noexcept { return -x; }
  static constexpr X power(const X &x, ll n) noexcept { return X(n) * x; }
  static constexpr X unit() { return X(0); }
  static constexpr bool commute = true;
};
#line 2 "alg/monoid/minmax.hpp"

template <class X>
struct Monoid_MinMax {
  using P = pair<X, X>;
  using value_type = P;
  static constexpr P op(const P x, const P y) noexcept {
    return {min(x.fi, y.fi), max(x.se, y.se)};
  }
  static constexpr P from_element(const X x) { return {x, x}; }
  static constexpr P unit() { return {infty<X>, -infty<X>}; }
  static constexpr bool commute = true;
};
#line 3 "alg/acted_monoid/minmax_add.hpp"

template <typename E>
struct ActedMonoid_MinMax_Add {
  using Monoid_X = Monoid_MinMax<E>;
  using Monoid_A = Monoid_Add<E>;
  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) {
    E lo = (x.fi == infty<E> ? x.fi : x.fi + a);
    E hi = (x.se == -infty<E> ? x.se : x.se + a);
    return {lo, hi};
  }
};
Back to top page