cp-library

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

View the Project on GitHub ttamx/cp-library

:warning: group/monoid-action/max-add.hpp

Depends on

Code

#pragma once
#include "group/monoid/add.hpp"
#include "group/monoid/max.hpp"

/**
 * Author: Teetat T.
 * Date: 2024-04-14
 * Description: Add to Max Action class.
 */

template<class T>
struct MaxAddAction{
    using InfoMonoid = MaxMonoid<T>;
    using TagMonoid = AddMonoid<T>;
    using Info = typename InfoMonoid::value_type;
    using Tag = typename TagMonoid::value_type;
    static constexpr Info op(const Info &a,const Tag &b){
        return (a==InfoMonoid::unit()?a:(a+b));
    }
};
#line 2 "group/monoid/add.hpp"

/**
 * Author: Teetat T.
 * Date: 2024-04-14
 * Description: Add Monoid class.
 */

template<class T>
struct AddMonoid{
    using value_type = T;
    static constexpr T op(const T &x,const T &y){return x+y;}
    static constexpr T inverse(const T &x){return -x;}
    static constexpr T unit(){return T(0);}
};

#line 2 "group/monoid/max.hpp"

/**
 * Author: Teetat T.
 * Date: 2024-04-14
 * Description: Max Monoid class.
 */

template<class T>
struct MaxMonoid{
    using value_type = T;
    static constexpr T op(const T &x,const T &y){return max(x,y);}
    static constexpr T unit(){return numeric_limits<T>::min();}
};

#line 4 "group/monoid-action/max-add.hpp"

/**
 * Author: Teetat T.
 * Date: 2024-04-14
 * Description: Add to Max Action class.
 */

template<class T>
struct MaxAddAction{
    using InfoMonoid = MaxMonoid<T>;
    using TagMonoid = AddMonoid<T>;
    using Info = typename InfoMonoid::value_type;
    using Tag = typename TagMonoid::value_type;
    static constexpr Info op(const Info &a,const Tag &b){
        return (a==InfoMonoid::unit()?a:(a+b));
    }
};
Back to top page