library/algebra/lazy/SetMin.hpp
Depends on
Verified with
Code
#pragma once
#include "library/algebra/monoid/Min.hpp"
#include "library/algebra/monoid/Set.hpp"
template < typename X > struct LazySetMin {
using MX = MonoidMin < X > ;
using MF = MonoidSet < X > ;
using F = typename MF :: value_type ;
static constexpr X mapping ( const F & f , const X & x ) { return f . value_or ( x ); }
};
#line 1 "library/algebra/monoid/Min.hpp"
template < typename X > struct MonoidMin {
using value_type = X ;
static constexpr X op ( const X & x , const X & y ) noexcept {
return std :: min ( x , y );
}
static constexpr void Rchop ( X & x , const X & y ) {
if ( x > y )
x = y ;
}
static constexpr void Lchop ( const X & x , X & y ) {
if ( y > x )
y = x ;
}
static constexpr X unit () { return std :: numeric_limits < X >:: max () / 2 ; }
static constexpr bool commute = true ;
};
#line 2 "library/algebra/monoid/Set.hpp"
// 合成の順番は関数と一緒だよ
template < typename X > struct MonoidSet {
using O = std :: optional < X > ;
using value_type = O ;
static constexpr O op ( const O & x , const O & y ) noexcept {
return ( x . has_value () ? x : y );
}
static constexpr void Rchop ( O & x , const O & y ) {
if ( ! x )
x = y ;
}
static constexpr void Lchop ( const O & x , O & y ) {
if ( x )
y = x ;
}
static constexpr O unit () noexcept { return std :: nullopt ; }
static constexpr bool commute = false ;
};
#line 4 "library/algebra/lazy/SetMin.hpp"
template < typename X > struct LazySetMin {
using MX = MonoidMin < X > ;
using MF = MonoidSet < X > ;
using F = typename MF :: value_type ;
static constexpr X mapping ( const F & f , const X & x ) { return f . value_or ( x ); }
};
Back to top page