CompetitiveProgrammingCpp

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

View the Project on GitHub

:heavy_check_mark: Library/Utility/Tools.hpp

Verified with

Code

#pragma once

#include <vector>

namespace mtd {

  template <class T, class S>
  inline auto chmax(T& t, const S& s) {
    if (s > t) {
      t = s;
      return true;
    }
    return false;
  }

  template <class T, class S>
  inline auto chmin(T& t, const S& s) {
    if (s < t) {
      t = s;
      return true;
    }
    return false;
  }

  template <class S>
  constexpr auto vec(S x) {
    return x;
  }

  template <class S, class... T>
  constexpr auto vec(S x, int n, T... ns) {
    return std::vector(n, vec(x, ns...));
  }

}  // namespace mtd
#line 2 "Library/Utility/Tools.hpp"

#include <vector>

namespace mtd {

  template <class T, class S>
  inline auto chmax(T& t, const S& s) {
    if (s > t) {
      t = s;
      return true;
    }
    return false;
  }

  template <class T, class S>
  inline auto chmin(T& t, const S& s) {
    if (s < t) {
      t = s;
      return true;
    }
    return false;
  }

  template <class S>
  constexpr auto vec(S x) {
    return x;
  }

  template <class S, class... T>
  constexpr auto vec(S x, int n, T... ns) {
    return std::vector(n, vec(x, ns...));
  }

}  // namespace mtd
Back to top page