#include<stdio.h>
int map[4][4]={'.','.','.','.',
      '#','.','.','.',
      '.','#','.','.',
      '#','.','.','@'};
int mov1[4]={0,0,1,-1};
int mov2[4]={1,-1,0,0};
typedef struct node
{
 int x;
 int y;
}node;
node dui[100];
int tou=0;
int wei=1;
void bfs()
{
 int nx;
 int ny;
 dui[tou].x=3;
 dui[tou].y=3;
 while(tou<wei)
 {
  for(int i=0;i<4;i++)
  {
   nx=dui[tou].x+mov1[i];
   ny=dui[tou].y+mov2[i];
   if(nx>=0&&nx<4&&ny>=0&&ny<4&&map[nx][ny]=='.')
   {
    dui[wei].x=nx;
    dui[wei].y=ny;
    map[nx][ny]='#';
    wei++;
   }
  }
  tou++;
 }
}
int main()
{
 bfs();
 printf("%d",tou);
 return 0;
}

poj1979的更多相关文章

  1. POJ1979 Red and Black (简单DFS)

    POJ1979 Description There is a rectangular room, covered with square tiles. Each tile is colored eit ...

  2. poj1979 Red And Black(DFS)

    题目链接 http://poj.org/problem?id=1979 思路 floodfill问题,使用dfs解决 代码 #include <iostream> #include < ...

  3. 《挑战程序设计竞赛》2.1 深度优先搜索 POJ2386 POJ1979 AOJ0118 AOJ0033 POJ3009

    POJ2386 Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 25366   Accepted: ...

  4. HDU1312 / POJ1979 / ZOJ2165 Red and Black(红与黑) 解题报告

    题目链接:pid=1312" target="_blank">HDU1312 / POJ1979 / ZOJ2165 Red and Black(红与黑) Red ...

  5. POJ1979(Red and Black)--FloodFill

    题目在这里 题目意思是这样的,一个人起始位置在    '@'  处,他在途中能到达的地方为 ' .  '     而  '#' 是障碍物,他不能到达. 问途中他所有能到达的   '.'的数量是多少 ? ...

  6. POJ-1979 Red and Black(DFS)

    题目链接:http://poj.org/problem?id=1979 深度优先搜索非递归写法 #include <cstdio> #include <stack> using ...

  7. POJ1979 Red and Black

    速刷一道DFS Description There is a rectangular room, covered with square tiles. Each tile is colored eit ...

  8. Poj1979 Red and Black (DFS)

    Red and Black Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 47466   Accepted: 25523 D ...

  9. poj-1979 red and black(搜索)

    Time limit1000 ms Memory limit30000 kB There is a rectangular room, covered with square tiles. Each ...

随机推荐

  1. java_ant详解

    转自:http://hi.baidu.com/victorlin23/item/721b892c770be3d7a517b695 1,什么是antant是构建工具2,什么是构建概念到处可查到,形象来说 ...

  2. 【vijos1066】弱弱的战壕 线段树

    描述 永恒和mx正在玩一个即时战略游戏,名字嘛~~~~~~恕本人记性不好,忘了-_-b. mx在他的基地附近建立了n个战壕,每个战壕都是一个独立的作战单位,射程可以达到无限(“mx不赢定了?!?”永恒 ...

  3. JavaScript表单提交四种方式

    总结JavaScript表单提交四种方式 <!DOCTYPE html> <html> <head> <title>JavaScript表单提交四种方式 ...

  4. Collection总结一览

    Java中集合大家族的成员实在是太丰富了,有常用的ArrayList.HashMap.HashSet,也有不常用的Stack.Queue,有线程安全的Vector.HashTable,也有线程不安全的 ...

  5. 手持扫描打印终端POS机应用商场零售批发移动销售开单

    无线开单系统,通过此无线开单系统,使用者可以进行日常的盘点.开单等作业.与进销存软件实时对接,可以提供给使用者即时.准确的库存数量.商品价格等信息.手持系统易上手.一次配置即可使用,极大的方便了使用者 ...

  6. HashMap两种遍历数据的方式

    HashMap的遍历有两种方式,一种是entrySet的方式,另外一种是keySet的方式. 第一种利用entrySet的方式: Map map = new HashMap(); Iterator i ...

  7. BZOJ1834 [ZJOI2010]network 网络扩容(最小费用最大流)

    挺直白的构图..最小费用最大流的定义. #include<cstdio> #include<cstring> #include<queue> #include< ...

  8. BZOJ3924 [Zjoi2015]幻想乡战略游戏

    Description 傲娇少女幽香正在玩一个非常有趣的战略类游戏,本来这个游戏的地图其实还不算太大,幽香还能管得过来,但是不知道为什么现在的网游厂商把游戏的地图越做越大,以至于幽香一眼根本看不过来, ...

  9. CSS一些总结

    1. display block:块元素,默认宽度为100%,可以设置元素的宽高,默认占满一行.块元素包括div,h1-h6,form,table,ul,ol等: inline:行内元素,默认宽度为内 ...

  10. Ubuntu(Linux) 下 unzip 命令使用详解

    1.功能作用:解压缩zip文件 2.位置:/usr/bin/unzip 3.格式用法:unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist ...