noya2_Library

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

View the Project on GitHub noya2ruler/noya2_Library

:heavy_check_mark: misc/monoids.hpp

Required by

Verified with

Code

#pragma once

#include<limits>

namespace noya2{

template<typename T>
struct max_monoid {
    using value_type = T;
    static constexpr T op(const T &a, const T &b){ return max(a,b); }
    static constexpr T e(){ return std::numeric_limits<T>::min(); }
    static constexpr T inv(const T &a){ return e(); }
};
template<typename T>
struct min_monoid {
    using value_type = T;
    static constexpr T op(const T &a, const T &b){ return min(a,b); }
    static constexpr T e(){ return std::numeric_limits<T>::max(); }
    static constexpr T inv(const T &a){ return e(); }
};
template<typename T>
struct plus_group {
    using value_type = T;
    static constexpr T op(const T &a, const T &b){ return a + b; }
    static constexpr T e(){ return T(0); }
    static constexpr T inv(const T &a){ return -a; }
};
template<typename T>
struct xor_group {
    using value_type = T;
    static constexpr T op(const T &a, const T &b){ return a ^ b; }
    static constexpr T e(){ return T(0); }
    static constexpr T inv(const T &a){ return a; }
};
    
} // namespace noya2
#line 2 "misc/monoids.hpp"

#include<limits>

namespace noya2{

template<typename T>
struct max_monoid {
    using value_type = T;
    static constexpr T op(const T &a, const T &b){ return max(a,b); }
    static constexpr T e(){ return std::numeric_limits<T>::min(); }
    static constexpr T inv(const T &a){ return e(); }
};
template<typename T>
struct min_monoid {
    using value_type = T;
    static constexpr T op(const T &a, const T &b){ return min(a,b); }
    static constexpr T e(){ return std::numeric_limits<T>::max(); }
    static constexpr T inv(const T &a){ return e(); }
};
template<typename T>
struct plus_group {
    using value_type = T;
    static constexpr T op(const T &a, const T &b){ return a + b; }
    static constexpr T e(){ return T(0); }
    static constexpr T inv(const T &a){ return -a; }
};
template<typename T>
struct xor_group {
    using value_type = T;
    static constexpr T op(const T &a, const T &b){ return a ^ b; }
    static constexpr T e(){ return T(0); }
    static constexpr T inv(const T &a){ return a; }
};
    
} // namespace noya2
Back to top page