POJ1979 Red and Black (简单DFS)】的更多相关文章

POJ1979 Description There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can mo…
Red and Black Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12519    Accepted Submission(s): 7753 Problem Description There is a rectangular room, covered with square tiles. Each tile is color…
题目: 简单dfs,没什么好说的 代码: #include <iostream> using namespace std; typedef long long ll; #define INF 2147483647 int w,h; ][]; ][] = {-,,,,,-,,}; ; void dfs(int x,int y){ || x >= h || y < || y >= w || a[x][y] == '#') return; ans++; a[x][y] = '#';…
http://poj.org/problem?id=1979 基础搜索. #include <iostream> #include <cstdio> #include <cmath> #include <vector> #include <cstring> #include <string> #include <algorithm> #include <string> #include <set>…
Red and Black Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 47466   Accepted: 25523 Description There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a…
题目链接:http://poj.org/problem?id=1979 深度优先搜索非递归写法 #include <cstdio> #include <stack> using namespace std; , MAX_H = ; ]; int W, H; int DFS(int sx, int sy); int main() { && W != && H != ) { ; i < W; i++) scanf("%s", M…
题目在这里 题意 : 问你按照图中所给的提示走,多少步能走出来??? 其实只要根据这个提示走下去就行了.模拟每一步就OK,因为下一步的操作和上一步一样,所以简单dfs.如果出现loop状态,只要记忆每个所到的点的第一次的步数,最后总步数减掉它即可 /************************************************************************* > File Name: poj1573.cpp > Author: YeGuoSheng >…
Problem Description There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can mo…
题目链接 http://poj.org/problem?id=1979 思路 floodfill问题,使用dfs解决 代码 #include <iostream> #include <cstring> #include <cstdio> using namespace std; const int N = 20; char maze[N][N]; int visit[N][N]; int dir[4][2] = {{-1, 0}, {0 ,1}, {1, 0}, {0,…
-->Red and Black Descriptions: 有个铺满方形瓷砖的矩形房间,每块瓷砖的颜色非红即黑.某人在一块砖上,他可以移动到相邻的四块砖上.但他只能走黑砖,不能走红砖. 敲个程序统计一下这样可以走到几块红砖上. Input  多组测试用例.每组数组开头有两个正整数W和H:W与H分别表示 x- 与 y- 方向上瓷砖的数量.W和W均不超过20. 还有H行数据,每行包含W个字符.每个字符表示各色瓷砖如下. '.' - 一块黑砖 '#' - 一块红砖 '@' - 一个黑砖上的人(一组数…