proconlib

This documentation is automatically generated by competitive-verifier/competitive-verifier

View the Project on GitHub anqooqie/proconlib

:heavy_check_mark: Typical groups (tools/groups.hpp)

They are typical groups.

License

Author

groups::bit_xor

template <typename G> struct groups::bit_xor;

It is a group $(G, \oplus, 0)$.

Constraints

Time Complexity

groups::bit_xor::T

using T = G;

It is an alias for <G>.

Constraints

Time Complexity

groups::bit_xor::op

static G op(G x, G y);

It returns x ^ y.

Constraints

Time Complexity

groups::bit_xor::e

static G e();

It returns G(0).

Constraints

Time Complexity

groups::bit_xor::inv

static G inv(G x);

It returns x.

Constraints

Time Complexity

groups::multiplies

template <typename G> struct groups::multiplies;

It is a group $(G, \times, 1)$.

Constraints

Time Complexity

groups::multiplies::T

using T = G;

It is an alias for <G>.

Constraints

Time Complexity

groups::multiplies::op

static G op(G x, G y);

It returns x * y.

Constraints

Time Complexity

groups::multiplies::e

static G e();

It returns G(1).

Constraints

Time Complexity

groups::multiplies::inv

static G inv(G x);

It returns G(1) / x.

Constraints

Time Complexity

groups::plus

template <typename G> struct groups::plus;

It is a group $(G, +, 0)$.

Constraints

Time Complexity

groups::plus::T

using T = G;

It is an alias for <G>.

Constraints

Time Complexity

groups::plus::op

static G op(G x, G y);

It returns x + y.

Constraints

Time Complexity

groups::plus::e

static G e();

It returns G(0).

Constraints

Time Complexity

groups::plus::inv

static G inv(G x);

It returns -x.

Constraints

Time Complexity

Depends on

Required by

Verified with

Code

#ifndef TOOLS_GROUPS_HPP
#define TOOLS_GROUPS_HPP

#include <cstddef>
#include <type_traits>
#include "tools/arithmetic.hpp"

namespace tools {
  namespace groups {
    template <typename G>
    struct bit_xor {
      using T = G;
      static T op(const T& x, const T& y) {
        return x ^ y;
      }
      static T e() {
        return T(0);
      }
      static T inv(const T& x) {
        return x;
      }
    };

    template <typename G>
    struct multiplies {
      using T = G;
      static T op(const T& x, const T& y) {
        return x * y;
      }
      static T e() {
        return T(1);
      }
      static T inv(const T& x) {
        return e() / x;
      }
    };

    template <typename G>
    struct plus {
      using T = G;
      static T op(const T& x, const T& y) {
        return x + y;
      }
      static T e() {
        return T(0);
      }
      static T inv(const T& x) {
        return -x;
      }
    };
  }
}

#endif
#line 1 "tools/groups.hpp"



#include <cstddef>
#include <type_traits>
#line 1 "tools/arithmetic.hpp"



#include <concepts>
#line 1 "tools/integral.hpp"



#line 1 "tools/is_integral.hpp"



#line 5 "tools/is_integral.hpp"

namespace tools {
  template <typename T>
  struct is_integral : std::is_integral<T> {};

  template <typename T>
  inline constexpr bool is_integral_v = tools::is_integral<T>::value;
}


#line 5 "tools/integral.hpp"

namespace tools {
  template <typename T>
  concept integral = tools::is_integral_v<T>;
}


#line 6 "tools/arithmetic.hpp"

namespace tools {
  template <typename T>
  concept arithmetic = tools::integral<T> || std::floating_point<T>;
}


#line 7 "tools/groups.hpp"

namespace tools {
  namespace groups {
    template <typename G>
    struct bit_xor {
      using T = G;
      static T op(const T& x, const T& y) {
        return x ^ y;
      }
      static T e() {
        return T(0);
      }
      static T inv(const T& x) {
        return x;
      }
    };

    template <typename G>
    struct multiplies {
      using T = G;
      static T op(const T& x, const T& y) {
        return x * y;
      }
      static T e() {
        return T(1);
      }
      static T inv(const T& x) {
        return e() / x;
      }
    };

    template <typename G>
    struct plus {
      using T = G;
      static T op(const T& x, const T& y) {
        return x + y;
      }
      static T e() {
        return T(0);
      }
      static T inv(const T& x) {
        return -x;
      }
    };
  }
}


Back to top page