proconlib

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

View the Project on GitHub anqooqie/proconlib

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

They are typical groups.

License

Author

group::plus

namespace group {
  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;
    }
  };
}

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

Constraints

Time Complexity

group::multiplies

namespace group {
  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;
    }
  };
}

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

Constraints

Time Complexity

group::bit_xor

namespace group {
  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;
    }
  };
}

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

Constraints

Time Complexity

Required by

Verified with

Code

#ifndef TOOLS_GROUP_HPP
#define TOOLS_GROUP_HPP

namespace tools {
  namespace group {
    template <typename G>
    struct plus {
      using T = G;
      static T op(const T& lhs, const T& rhs) {
        return lhs + rhs;
      }
      static T e() {
        return T(0);
      }
      static T inv(const T& v) {
        return -v;
      }
    };

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

    template <typename G>
    struct bit_xor {
      using T = G;
      static T op(const T& lhs, const T& rhs) {
        return lhs ^ rhs;
      }
      static T e() {
        return T(0);
      }
      static T inv(const T& v) {
        return v;
      }
    };
  }
}

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



namespace tools {
  namespace group {
    template <typename G>
    struct plus {
      using T = G;
      static T op(const T& lhs, const T& rhs) {
        return lhs + rhs;
      }
      static T e() {
        return T(0);
      }
      static T inv(const T& v) {
        return -v;
      }
    };

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

    template <typename G>
    struct bit_xor {
      using T = G;
      static T op(const T& lhs, const T& rhs) {
        return lhs ^ rhs;
      }
      static T e() {
        return T(0);
      }
      static T inv(const T& v) {
        return v;
      }
    };
  }
}


Back to top page