HDU1198水管并查集Farm Irrigation】的更多相关文章

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 pipes, which is marked…
今天开始(第三轮)并查集,,之前学的忘了一些 本题很简单直接上代码 #include<iostream> #include<cstring> #include<cstdio> #define MAXN 55 using namespace std; int F[MAXN*MAXN]; int find(int x){ ) return x; return F[x]=find(F[x]); } void bing(int a,int b){ int t1=find(a);…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1198 dfs: #include<cstdio>//hdu1198 dfs #include<cstring> ][] = { {,,,,},{,,,,},{,,,,},{,,,,},{,,,,},{,,,,},{,,,,},{,,,,},{,,,,},{,,,,},{,,,,}}; ][] = {,,,,,,,,,}, mov[][] = {,,-,,,,,-}; ][],id[][…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1198 简单并查集 分别合并竖直方向和水平方向即可 代码: #include<iostream> #include<cstdlib> #include<cstdio> #include<cstring> #define maxn 110 using namespace std; int parent[maxn*maxn]; char map[maxn][maxn]…
Farm Irrigation Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 6   Accepted Submission(s) : 3 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description Benny has a spacious fa…
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…
转载请注明出处:viewmode=contents">http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1198 ----------------------------------------------------------------------------------------------------------------------…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1198 题目大意: 有如上图11种土地块,块中的绿色线条为土地块中修好的水渠,现在一片土地由上述的各种土地块组成,需要浇水,问需要打多少口井. 例如下面这个土地块 ADC FJKIHE then the water pipes are distributed like 解题思路: 首先模拟A-K的四个不同的方向,用了一个数组表示从A-K的四个方向是否有水管 然后枚举每个点的四个方向上可到达的地方,如…
题意: 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 pipes, which is ma…
畅通工程 Problem Description 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇.省政府"畅通工程"的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可).问最少还需要建设多少条道路?    Input 测试输入包含若干测试用例.每个测试用例的第1行给出两个正整数,分别是城镇数目N ( < 1000 )和道路数目M:随后的M行对应M条道路,每行给出一对正整数,分别是该条道路直接连通的两个…