hdu1198Farm Irrigation (DFS)】的更多相关文章

题目链接: 啊哈哈,选我选我 思路是:首先依据图像抽象出联通关系.. 首先确定每一种图形的联通关系.用01值表示不连通与不连通... 然后从第1个图形进行dfs搜索.假设碰到两快田地能够联通的话那么标记..注意处理的过程中你的 搜索顺序要和你的每一个图形的连通性的顺序同样. .然后就是最后看上下. 左右是否能匹配.. . 看最后有几个不同的快,这就是答案,感觉跟并查集一样..并查集应该也能够做. . 题目: Farm Irrigation Time Limit: 2000/1000 MS (Ja…
Problem Description Benny has a spacious farm land to irrigate. The farm land is a rectangle, and is divided into a lot of samll squares. Water pipes are placed in these squares. Different square has a different type of pipe. There are 11 types of pi…
Farm Irrigation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6590    Accepted Submission(s): 2838 Problem Description Benny has a spacious farm land to irrigate. The farm land is a rectangle…
意甲冠军  两个农田管内可直接连接到壳体  他们将能够共享一个水源   有11种农田  管道的位置高于一定  一个农田矩阵  问至少须要多少水源 DFS的连通块问题  两个相邻农田的管道能够直接连接的话他们就属于一个连通块  题目就是求连通块个数 #include<cstdio> #include<cstring> using namespace std; const int N = 55; char mat[N][N]; int type[11][4] = { //相应11种水管…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1198 dfs: #include<cstdio>//hdu1198 dfs #include<cstring> ][] = { {,,,,},{,,,,},{,,,,},{,,,,},{,,,,},{,,,,},{,,,,},{,,,,},{,,,,},{,,,,},{,,,,}}; ][] = {,,,,,,,,,}, mov[][] = {,,-,,,,,-}; ][],id[][…
Farm Irrigation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4977    Accepted Submission(s): 2137 Problem Description Benny has a spacious farm land to irrigate. The farm land is a rectangle…
Farm Irrigation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11188    Accepted Submission(s): 4876 Problem Description Benny has a spacious farm land to irrigate. The farm land is a rectangle…
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=1198 题目: Farm Irrigation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10132    Accepted Submission(s): 4464 Problem Description Benny has a spac…
题目链接 DFS的简单应用,比较繁琐的是处理输入的英文字母.用并查集也可以做(可是笔者现在还没有掌握并查集,之前只用过一次,以后学会回来补上) #include<cstdio> #include<cstring> using namespace std; ][]={{,,,},{,,,},{,,,},{,,,},{,,,},{,,,},{,,,},{,,,},{,,,},{,,,},{,,,},{,,,}}; ][]={{-,},{,-},{,},{,}},a[][],cnt;//…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1198 有题目图11种土地块,块中的绿色线条为土地块中修好的水渠,现在一片土地由上述的各种土地块组成,需要浇水,问需要打多少口井 比如 ADCFJKIHE是下图这种情况 需要打三口井,其实想多了就是集合合并差不多,用并查集可以解决,将每个格子按顺序是从0到n*m-1,然后根据连接情况判断是否相连然后合并 第一次写成了暴力的,虽然一遍过了,但是觉得太长了,然后又改成了下面简洁并查集的,还有下下面的dfs的…