#include #include using namespace std; typedef pair pii; int W, H; int M[100][100]; bool reached[100][100]; bool flag=false; const pii dd[]={{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; bool is(int h, int w){ return (0<=h&&h> W>> H; for(int i=0; i> M[i][j]; } } set st; for(int i=0; i