poj1979
#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的更多相关文章
- POJ1979 Red and Black (简单DFS)
POJ1979 Description There is a rectangular room, covered with square tiles. Each tile is colored eit ...
- poj1979 Red And Black(DFS)
题目链接 http://poj.org/problem?id=1979 思路 floodfill问题,使用dfs解决 代码 #include <iostream> #include < ...
- 《挑战程序设计竞赛》2.1 深度优先搜索 POJ2386 POJ1979 AOJ0118 AOJ0033 POJ3009
POJ2386 Lake Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 25366 Accepted: ...
- HDU1312 / POJ1979 / ZOJ2165 Red and Black(红与黑) 解题报告
题目链接:pid=1312" target="_blank">HDU1312 / POJ1979 / ZOJ2165 Red and Black(红与黑) Red ...
- POJ1979(Red and Black)--FloodFill
题目在这里 题目意思是这样的,一个人起始位置在 '@' 处,他在途中能到达的地方为 ' . ' 而 '#' 是障碍物,他不能到达. 问途中他所有能到达的 '.'的数量是多少 ? ...
- POJ-1979 Red and Black(DFS)
题目链接:http://poj.org/problem?id=1979 深度优先搜索非递归写法 #include <cstdio> #include <stack> using ...
- POJ1979 Red and Black
速刷一道DFS Description There is a rectangular room, covered with square tiles. Each tile is colored eit ...
- Poj1979 Red and Black (DFS)
Red and Black Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 47466 Accepted: 25523 D ...
- poj-1979 red and black(搜索)
Time limit1000 ms Memory limit30000 kB There is a rectangular room, covered with square tiles. Each ...
随机推荐
- Java和Android注释规范
1. 文件头注释 每一个文件的文件头都必须做文件头注释.文件头注释范例如下: /* * 文件名:LoginActivity * 描 述:对用户 * 作 者: * 时 间: * 版 权: */ 2. ...
- 只用CSS美化选择框
只用CSS美化选择框 2012-03-02 11:04 by iBlog, 26240 阅读, 14 评论, 收藏, 编辑 <本文译自Style a Select Box Using Only ...
- 2016.7.9 计算机网络复习要点第四章之虚拟专用网VPN和网络地址转换NAT
1.虚拟专用网VPN (1)一个机构内,对于那些仅在本机构内部使用的计算机就可以由本季候自行分配其IP地址,让这些计算机使用仅在本机构有效的IP地址(本地地址),不需要申请全球唯一的IP地址(全球地址 ...
- 解决Fiddler无法抓到手机的会话包
解决Fiddler无法抓到手机的会话包 使用Fiddler抓手机的会话包涉及多个方面,所以容易出现无法抓取包的情况.遇到这类问题,需要按照以下顺序进行检查和排除. (1)在Fiddler中设置 ...
- Making raycast ignore multiple layers
I know how to make the raycast ignore a layer but I want it to ignore layers 9 and 10 but collide wi ...
- 游戏 scrollView
using UnityEngine; using System.Collections; public class LLL : MonoBehaviour { Vector2 scrollPositi ...
- BZOJ3630 : [JLOI2014]镜面通道
从左边不能到达右边当且仅当存在一条与上下底边相连的分割线将它们分开 设下底边为S,上底边为T,每个元件作为点,有公共部分的两个点互相连边 最后拆点求最小割 #include<cstdio> ...
- C#线程间同步无法关闭
用C#做了个线程间同步的小程序,但每次关闭窗口后进程仍然在,是什么原因? 解决方法: 要加一句 线程.IsBackground = true; 否则退出的只是窗体 上面的方法没看懂... MSDN上说 ...
- windows 8 项目
展示图 建议搜索: 线路查询: 应用商店式瀑布浏览(语义缩放): 路线规划:
- js控制页面的全屏展示和退出全屏显示
<!DOCTYPE html> <html> <meta http-equiv="Content-Type" content="text/h ...