This documentation is automatically generated by online-judge-tools/verification-helper
#include "Src/Algebra/Monoid/ChmaxMonoid.hpp"
#pragma once
#include "../../Template/TypeAlias.hpp"
#include <algorithm>
#include <optional>
namespace zawa {
template <class T, class U>
class ChmaxMonoidData {
private:
std::optional<T> priority_{};
U value_{};
public:
ChmaxMonoidData() = default;
ChmaxMonoidData(const U& value)
: priority_{std::nullopt}, value_{value} {}
ChmaxMonoidData(const T& priority, const U& value)
: priority_{priority}, value_{value} {}
constexpr bool infty() const noexcept {
return !priority_.has_value();
}
constexpr const T& priority() const noexcept {
return priority_.value();
}
constexpr const U& value() const noexcept {
return value_;
}
friend constexpr bool operator>(const ChmaxMonoidData& l, const ChmaxMonoidData& r) {
if (l.infty()) return false;
else if (r.infty()) return true;
else return l.priority() > r.priority();
}
};
template <class T, class U>
struct ChmaxMonoid {
using Element = ChmaxMonoidData<T, U>;
static Element identity() noexcept {
return Element{};
}
// タイブレークはl側を優先するようになっている。
static Element operation(const Element& l, const Element& r) noexcept {
return (r > l ? r : l);
}
};
} // namespace zawa
#line 2 "Src/Algebra/Monoid/ChmaxMonoid.hpp"
#line 2 "Src/Template/TypeAlias.hpp"
#include <cstdint>
#include <cstddef>
namespace zawa {
using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;
using i128 = __int128_t;
using u8 = std::uint8_t;
using u16 = std::uint16_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using usize = std::size_t;
} // namespace zawa
#line 4 "Src/Algebra/Monoid/ChmaxMonoid.hpp"
#include <algorithm>
#include <optional>
namespace zawa {
template <class T, class U>
class ChmaxMonoidData {
private:
std::optional<T> priority_{};
U value_{};
public:
ChmaxMonoidData() = default;
ChmaxMonoidData(const U& value)
: priority_{std::nullopt}, value_{value} {}
ChmaxMonoidData(const T& priority, const U& value)
: priority_{priority}, value_{value} {}
constexpr bool infty() const noexcept {
return !priority_.has_value();
}
constexpr const T& priority() const noexcept {
return priority_.value();
}
constexpr const U& value() const noexcept {
return value_;
}
friend constexpr bool operator>(const ChmaxMonoidData& l, const ChmaxMonoidData& r) {
if (l.infty()) return false;
else if (r.infty()) return true;
else return l.priority() > r.priority();
}
};
template <class T, class U>
struct ChmaxMonoid {
using Element = ChmaxMonoidData<T, U>;
static Element identity() noexcept {
return Element{};
}
// タイブレークはl側を優先するようになっている。
static Element operation(const Element& l, const Element& r) noexcept {
return (r > l ? r : l);
}
};
} // namespace zawa