proconlib

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

View the Project on GitHub KodamaD/proconlib

:warning: traits/max_add_action.cpp

Depends on

Code

#pragma once
#include "max_monoid.cpp"
#include "sum_group.cpp"

template <class T> struct MaxAddAction {
    using Monoid = MaxMonoid<T>;
    using Effector = SumGroup<T>;
    static constexpr std::optional<T> operation(const std::optional<T>& l, const T& r) {
        if (!l) return std::nullopt;
        return std::optional<T>(std::in_place, *l + r);
    }
};
#line 2 "traits/max_monoid.cpp"
#include <algorithm>
#line 2 "traits/optional_monoid.cpp"
#include <optional>
#include <utility>

template <class S> struct OptionalMonoid {
    using Type = std::optional<typename S::Type>;
    static constexpr Type identity() { return std::nullopt; }
    static constexpr Type operation(const Type& l, const Type& r) {
        if (!l) return r;
        if (!r) return l;
        return Type(std::in_place, S::operation(*l, *r));
    }
};
#line 4 "traits/max_monoid.cpp"

template <class T> struct MaxSemiGroup {
    using Type = T;
    static constexpr T operation(const T& l, const T& r) { return std::max(l, r); }
};

template <class T> using MaxMonoid = OptionalMonoid<MaxSemiGroup<T>>;
#line 2 "traits/sum_group.cpp"

template <class T> struct SumGroup {
    using Type = T;
    static constexpr T identity() { return T(0); }
    static constexpr T operation(const T& l, const T& r) { return l + r; }
    static constexpr T inverse(const T& x) { return -x; }
};
#line 4 "traits/max_add_action.cpp"

template <class T> struct MaxAddAction {
    using Monoid = MaxMonoid<T>;
    using Effector = SumGroup<T>;
    static constexpr std::optional<T> operation(const std::optional<T>& l, const T& r) {
        if (!l) return std::nullopt;
        return std::optional<T>(std::in_place, *l + r);
    }
};
Back to top page