This documentation is automatically generated by online-judge-tools/verification-helper
#include "src/utility/monoid/rangeAddMonoid.hpp"
加法のモノイドを表現した構造体です。RAQで利用できます
作用を表現する構造体でa.value + a.size * hoge
とするといい感じになります。
テンプレート引数 T
: 型、operator +
が定義されているもの
T value
: 保持している値
std::size_t size
: 保持している区間の長さ
テンプレート引数 T
: dat
のT
に利用される
using valueType = dat<T>
static constexpr valueType identity
value = 0
、size = 0ULL
static valueType opration(const valueType& a, const valueType& b)
value = a.value + b.value
size = a.size + b.size
#pragma once
#include <cstddef>
namespace zawa {
template <class T>
struct dat {
T value;
std::size_t size;
constexpr dat(const T& value = 0, const std::size_t& size = 0ULL) : value(value), size(size) {}
};
template <class T>
struct rangeAddMonoid {
using valueType = dat<T>;
static constexpr valueType identity{};
static valueType operation(const valueType& a, const valueType& b) {
return valueType(a.value + b.value, a.size + b.size);
}
};
} // namespace zawa
#line 2 "src/utility/monoid/rangeAddMonoid.hpp"
#include <cstddef>
namespace zawa {
template <class T>
struct dat {
T value;
std::size_t size;
constexpr dat(const T& value = 0, const std::size_t& size = 0ULL) : value(value), size(size) {}
};
template <class T>
struct rangeAddMonoid {
using valueType = dat<T>;
static constexpr valueType identity{};
static valueType operation(const valueType& a, const valueType& b) {
return valueType(a.value + b.value, a.size + b.size);
}
};
} // namespace zawa