#include <bits/stdc++.h> using namespace std; int dir[8][2] = {{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1},{-1,0}}; struct point { int x; int y; }; int bfs(int n, int m, int x, int y, int** A) { if(A[x][y]==0) return 0; point p{x,y}; queue<point> q; q.push(p); point cur; int sum = ...