poj2386(简单dfs)】的更多相关文章

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] = '#';…
题目在这里 题意 : 问你按照图中所给的提示走,多少步能走出来??? 其实只要根据这个提示走下去就行了.模拟每一步就OK,因为下一步的操作和上一步一样,所以简单dfs.如果出现loop状态,只要记忆每个所到的点的第一次的步数,最后总步数减掉它即可 /************************************************************************* > File Name: poj1573.cpp > Author: YeGuoSheng >…
就是求图中有多少个水洼.对图进行dfs遍历,并把是水洼的地方全部标记.然后从下一个是水哇的地方再进行dfs. #include <cstdio> #include <iostream> #include <cstring> using namespace std; ][]; int sum; ][]; , -, -, , , , , }; , , , -, , -, ,}; int row, col; bool check(int x, int y) { &&a…
转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://poj.org/problem?id=1562 --------------------------------------------------------------------------------------------------------------------------------------…
题目链接:http://poj.org/problem?id=2386 Description Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1 <= M <= 100) squares. Each square contains either wa…
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…
LINK 题意:给出n个数,\(a_i\)代表下一步会移动到第\(a_i\)个位置,并继续进行操作,\(b_i\)1代表进行一次翻面操作,要求不管以哪个位置上开始,最后都能满足 1.到达过所有位置 2.对到达的任意位置,都已经进行过奇次和偶次翻面操作 交换任意两个\(a_i\),或修改\(b_i\)的值算做一次操作 问最小操作数. 思路:首先可以知道,要满足条件1,必须使该排列的循环节长度为1(即所有数成一个环),再者要满足条件2,则\(b_i==1\)必须有奇数个. 那么很简单,对所有未标记的…
这道题看上去非常麻烦,什么迷宫啊.门之类的,事实上挺简单的,就是让把与 * 连通的都置为 # 包含 * , 直接dfs就能够了,只是我wa了好多次...最后居然是多读了一个换行.忘了加getchar()了,gets()函数 会把缓冲区里面的换行给读进去的...应该把换行去掉,血的教训啊.. . 代码: #include<stdio.h> #include<string.h> #include<stdlib.h> int dx[4]={-1,0,0,1}; int dy[…
Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18201   Accepted: 9192 Description Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100…