This documentation is automatically generated by online-judge-tools/verification-helper
#include "Src/Algebra/Monoid/MinMonoid.hpp"
std::optional<T>
を利用して、 $\infty$ を std::nullopt
で表現している。
std::optional<T>
の運用については std::optional cpprefjp 等も参考にすること。
#pragma once
#include <algorithm>
#include <optional>
namespace zawa {
template <class T>
class MinMonoid {
public:
using Element = std::optional<T>;
static constexpr Element identity() noexcept {
return std::nullopt;
}
static constexpr Element operation(const Element& l, const Element& r) noexcept {
if (l and r) {
return std::min(l, r);
}
else if (l) {
return l;
}
else if (r) {
return r;
}
else {
return std::nullopt;
}
}
};
} // namespace zawa
#line 2 "Src/Algebra/Monoid/MinMonoid.hpp"
#include <algorithm>
#include <optional>
namespace zawa {
template <class T>
class MinMonoid {
public:
using Element = std::optional<T>;
static constexpr Element identity() noexcept {
return std::nullopt;
}
static constexpr Element operation(const Element& l, const Element& r) noexcept {
if (l and r) {
return std::min(l, r);
}
else if (l) {
return l;
}
else if (r) {
return r;
}
else {
return std::nullopt;
}
}
};
} // namespace zawa