- Bit Magic, Graph, Matrix

Check if there are T number of continuous of blocks of 0s or not in given Binary Matrix

#include using namespace std;const long long M = 1e9 + 7;  vector directions    = { { 0, 1 }, { -1, 0 }, { 0, -1 },        { 1, 0 }, { 1, 1 }, { -1, -1 },        { -1, 1 }, { 1, -1 } };  bool isInside(int i, int j, int N, int M){    if (i >= 0 && i < N        && j >= 0 && j < M) {        return true;    }    return false;}  void DFS(vector mat, int N,         int M, int i, int j,         vector& visited){    if (visited[i][j] == true) {          return;    }      visited[i][j] = true;          for (auto it : directions) {        int I = i + it.first;        int J = j + it.second;        if (isInside(I, J, N, M)) {            if (mat[I][J] == 0) {                                  DFS(mat, N, M, I,                    J, visited);            }        }    }}  void check(int N, int M,           vector& mat){            int black = 0;      for (int i = 0; i < N; i++) {        for (int j = 0; j < M; j++) {            if (mat[i][j] == 0) {                black++;            }        }    }          if (black < 2 * (max(N, M))) {        cout