#include #include #include #include using namespace std; const int MAX_W = 20; const int MAX_H = 20; int W,H; int ap=0,bp=0; vector field; int Ax[MAX_W*MAX_H],Ay[MAX_W*MAX_H],Bx[MAX_W*MAX_H],By[MAX_W*MAX_H]; int dy[] = {1, 0, -1, 0}; int dx[] = { 0, 1, 0, -1 }; void dsf(int x,int y,int count) { if(count==0) { field[x][y] = 'A'; Ax[ap] = x, Ay[ap] = y; ap++; } else { field[x][y] = 'B'; Bx[bp] = x, By[bp] = y; bp++; } for(int i=0;i<4;i++) { int nx = x + dx[i], ny = y + dy[i]; if (0 <= nx && nx < H && 0 <= ny && ny < W && field[nx][ny]=='.') { dsf(nx,ny,count); } } return ; } void solve() { int min = W*H; int d; int count = 0; for(int h=0;h> W >> H; for(int i=0;i> tmp; field.push_back(tmp); } solve(); //for(int i=0;i