#include #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; #define MAX_H 3000 #define MAX_W 3000 using namespace std; int H,W; int A[MAX_H][MAX_W]; void dfs(int x, int y){ A[y][x] = 0; int nx, ny; //上 nx=x; ny=y+1; if(ny=0 && A[ny][nx]==1) dfs(nx,ny); //右 nx=x-1; ny=y; if(nx>=0 && A[ny][nx]==1) dfs(nx,ny); //左 nx=x+1; ny=y; if(nx> H >> W; for(int j=0; j> A[j][i]; solve(); }