HDU 1312 Red and Black(简单广搜)

题目呀链接:http://acm.hdu.edu.cn/showproblem.php?pid=1312

#include
#include
#include
using namespace std;
char map[22][22];
int W,H;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int bfs(int x,int y)
{
    queue q;
    int nx,ny,v,i,num=0,xx,yy;
    map[x][y]='#';
    v=x*H+y;
    q.push(v);
    while(!q.empty())
    {
        xx=q.front()/H;
        yy=q.front()%H;
      //  printf("xx=%d yy=%d\n",xx,yy);
        q.pop();num++;
        for(i=0;i<4;i++)
        {
            nx=xx+dx[i];ny=yy+dy[i];
            if(nx>=0&&ny>=0&&nx



你可能感兴趣的:(HDU 1312 Red and Black(简单广搜))