This #define
here:
#define ull unsigned long long
Should be changed to a typedef
instead, like this:
typedef unsigned long long ull;
This line here:
#define ll long long
Should also be changed to this:
typedef long long ll;
In general, if you're using #define
to shorten type names, you should be using typedef
instead.
You should also drop this line here:
using namespace std;
There are many things that can happen if you have this line, especially if you're working on a large project, and none of them are good. See this Stackoverflow answerthis Stackoverflow answer for more details.
There's also a reason it's named std
and not standard
. The prefix std
is shorter.
Your inRange
function should return
a bool
, like this:
bool inRange(int x, int y)
{
return x >= 0 && a < m && y >= 0 && y < n;
}
This eliminates the need for the if
statements.
Instead of defining your own custom infinity (INF
), you should be using std::numeric_limits<T>::infinity()
.
Finally, you don't need to return 0;
in main
. main
is a special function, so the compiler will automatically insert return 0;
if it isn't there.