proconlib

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

View the Project on GitHub anqooqie/proconlib

:heavy_check_mark: Check whether $(r, c)$ is in a grid of height $h$ and width $w$ (tools/is_in_grid.hpp)

template <typename T1, typename T2, typename T3, typename T4>
bool is_in_grid(T1 r, T2 c, T3 h, T4 w);

It returns $0 \leq r < h \land 0 \leq c < w$.

Constraints

Time Complexity

License

Author

Verified with

Code

#ifndef TOOLS_IS_IN_GRID_HPP
#define TOOLS_IS_IN_GRID_HPP

#include <cassert>
#include <utility>

namespace tools {
  template <typename T1, typename T2, typename T3, typename T4>
  constexpr bool is_in_grid(const T1 r, const T2 c, const T3 h, const T4 w) noexcept {
    assert(::std::cmp_greater_equal(h, 0));
    assert(::std::cmp_greater_equal(w, 0));
    return ::std::cmp_less_equal(0, r) && ::std::cmp_less(r, h) && ::std::cmp_less_equal(0, c) && ::std::cmp_less(c, w);
  }
}

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



#include <cassert>
#include <utility>

namespace tools {
  template <typename T1, typename T2, typename T3, typename T4>
  constexpr bool is_in_grid(const T1 r, const T2 c, const T3 h, const T4 w) noexcept {
    assert(::std::cmp_greater_equal(h, 0));
    assert(::std::cmp_greater_equal(w, 0));
    return ::std::cmp_less_equal(0, r) && ::std::cmp_less(r, h) && ::std::cmp_less_equal(0, c) && ::std::cmp_less(c, w);
  }
}


Back to top page