题意 给个无向图,无重边和自环,问最少需要多少路径把边覆盖了.并输出相应路径 分析 首先联通块之间是独立的,对于一个联通块内,最少路径覆盖就是  max(1,度数为奇数点的个数/2).然后就是求欧拉路径了,先将块内度数为奇数的点找出来,留下两个点,其余两两连上虚边,这样我们选择从一个奇数点出发到另一个奇数点,求出一条欧拉路径,统计总路径数.接着就dfs,注意一些细节. 附赠一个求欧拉回路的fleury算法:https://blog.csdn.net/u011466175/article/deta…
HDU 6311 Cover (无向图最小路径覆盖) Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1967 Accepted Submission(s): 442 Special Judge Problem Description The Wall has down and the King in the north has to sen…
The Wall has down and the King in the north has to send his soldiers to sentinel. The North can be regard as a undirected graph (not necessary to be connected), one soldier can cover one path. Today there's no so many people still breathing in the no…
题意:有最少用多少条边不重复的路径可以覆盖一个张无向图. 分析:对于一个连通块(单个点除外),如果奇度数点个数为 k,那么至少需要max{k/2,1}  条路径.将奇度数的点两两相连边(虚边),然后先从奇度数的点出发,搜索由其出发的欧拉回路.需要将遍历的边和其反向边打标记,并在DFS退栈的时候记录边的编号(前向星的存储是访问后加入的边),若该边是自己添加的虚边,那么说明实际上这次DFS搜索到的是一条欧拉通路,那么结果还需额外+1,所以对所有奇数点DFS过后,得到的结果就是max{k/2,1}.…
Cover Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1543    Accepted Submission(s): 321Special Judge Problem Description The Wall has down and the King in the north has to send his soldiers to…
题目链接:http://poj.org/problem?id=1422 Consider a town where all the streets are one-way and each street leads from one intersection to another. It is also known that starting from an intersection and walking through town's streets you can never reach t…
hdu 5386 Cover Description You have an matrix.Every grid has a color.Now there are two types of operating: L x y: for(int i=1;i<=n;i++)color[i][x]=y; H x y:for(int i=1;i<=n;i++)color[x][i]=y; Now give you the initial matrix and the goal matrix.There…
题意:有最少用多少条边不重复的路径可以覆盖一个张无向图 ,输出每条路径的边的序号 , 如果是反向就输出-id. 也就是可以多少次一笔画的方式画完这个无向图. 题解:我们已知最优胜的情况是整个图是欧拉图的时候 ,我们只需要一笔就搞定了 , 可是现在这个图并不是一个欧拉图, 所以现在问题是其转化为欧拉图 ,那我们根据欧拉图的性质 , 如果一个无向图是欧拉图的时候当且这个图有奇数的度的点有0个或者是2个 , 而且如果是两个的话那这两个点肯定是起点或者终点  ;  所以现在我们就遍历整个图的奇数点将其连…
http://acm.hdu.edu.cn/showproblem.php?pid=1151 Air Raid Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 7469   Accepted: 4451 Description Consider a town where all the streets are one-way and each street leads from one intersection to an…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1054 题目大意:给你一棵树,选取树上最少的节点使得可以覆盖整棵树. 解题思路: 首先树肯定是二分图,因为树可以奇偶分层,从而根据二分图染色的原理可以确定树是二分图.我们可以用染色法确定出两个集合求最大匹配,也可以将边补成双向的,然后将最大匹配/2. 代码: #include<iostream> #include<cstdio> #include<cstring> #incl…