#include using namespace std; #define int long long typedef pair P; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int H, W; int A[3100][3100]; void bfs(int sx, int sy) { A[sx][sy] = 1; queue

q; q.push(P(sx, sy)); while (q.size()) { P p = q.front(); q.pop(); int cx = p.first; int cy = p.second; for (int i=0; i<4; i++) { int nx = cx + dx[i]; int ny = cy + dy[i]; if (0<=nx && nx> H >> W; for (int i=0; i> A[i][j]; } } int ans = 0; for (int i=0; i