CompProgLibrary

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

View the Project on GitHub RTnF/CompProgLibrary

:warning: モノイド (Monoid)
(cpp/algebraic_structure/monoid.hpp)

Wikipedia - モノイド

群は集合と二項演算の組であって、以下の条件を満たす。

もし逆元があるなら、群になる。

コンストラクタ

Group g()

引数がない場合、単位元で初期化するものとする。

op

Group op(Group a, Group b)

演算 $a \cdot b$ を行う。

e

Group e()

単位元を返す。

モノイド

クラス名 対象の集合 二項演算 単位元
MonoidMul 整数、実数など 乗算 $1$
MonoidMax 整数、実数など $\max (a, b)$ 最小値または $-\infty$
MonoidMin 整数、実数など $\min (a, b)$ 最大値または $\infty$

Depends on

Code

#pragma once
#include "template/small_template.hpp"

template <class T = ll> struct MonoidMul {
  T x;
  MonoidMul(T x_) : x(x_) {}
  MonoidMul() : MonoidMul(e()) {}
  static MonoidMul e() { return 1; }
  friend MonoidMul op(const MonoidMul &a, const MonoidMul &b) {
    return a.x * b.x;
  }
};

template <class T = ll> struct MonoidMax {
  T x;
  MonoidMax(T x_) : x(x_) {}
  MonoidMax() : MonoidMax(e()) {}
  static MonoidMax e() { return numeric_limits<T>::min(); }
  friend MonoidMax op(const MonoidMax &a, const MonoidMax &b) {
    return max(a.x, b.x);
  }
};

template <class T = ll> struct MonoidMin {
  T x;
  MonoidMin(T x_) : x(x_) {}
  MonoidMin() : MonoidMin(e()) {}
  static MonoidMin e() { return numeric_limits<T>::max(); }
  friend MonoidMin op(const MonoidMin &a, const MonoidMin &b) {
    return min(a.x, b.x);
  }
};
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus.py", line 187, in bundle
    bundler.update(path)
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 401, in update
    self.update(self._resolve(pathlib.Path(included), included_from=path))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 260, in _resolve
    raise BundleErrorAt(path, -1, "no such header")
onlinejudge_verify.languages.cplusplus_bundle.BundleErrorAt: template/small_template.hpp: line -1: no such header
Back to top page