compro_library

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

View the Project on GitHub siro53/compro_library

:heavy_check_mark: data-structure/monoid/affine.hpp

Required by

Verified with

Code

#pragma once

#include <utility>

template <typename T, bool rev = false> struct MonoidAffine {
    using S = std::pair<T, T>;
    using value_type = S;
    inline static S op(const S &l, const S &r) {
        if(rev) return S(r.first * l.first, r.first * l.second + r.second);
        return S(l.first * r.first, l.first * r.second + l.second);
    }
    inline static S e() { return S(T(1), T(0)); }
};
#line 2 "data-structure/monoid/affine.hpp"

#include <utility>

template <typename T, bool rev = false> struct MonoidAffine {
    using S = std::pair<T, T>;
    using value_type = S;
    inline static S op(const S &l, const S &r) {
        if(rev) return S(r.first * l.first, r.first * l.second + r.second);
        return S(l.first * r.first, l.first * r.second + l.second);
    }
    inline static S e() { return S(T(1), T(0)); }
};
Back to top page