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…
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…
题意 给个无向图,无重边和自环,问最少需要多少路径把边覆盖了.并输出相应路径 分析 首先联通块之间是独立的,对于一个联通块内,最少路径覆盖就是  max(1,度数为奇数点的个数/2).然后就是求欧拉路径了,先将块内度数为奇数的点找出来,留下两个点,其余两两连上虚边,这样我们选择从一个奇数点出发到另一个奇数点,求出一条欧拉路径,统计总路径数.接着就dfs,注意一些细节. 附赠一个求欧拉回路的fleury算法:https://blog.csdn.net/u011466175/article/deta…
题意:有最少用多少条边不重复的路径可以覆盖一个张无向图. 分析:对于一个连通块(单个点除外),如果奇度数点个数为 k,那么至少需要max{k/2,1}  条路径.将奇度数的点两两相连边(虚边),然后先从奇度数的点出发,搜索由其出发的欧拉回路.需要将遍历的边和其反向边打标记,并在DFS退栈的时候记录边的编号(前向星的存储是访问后加入的边),若该边是自己添加的虚边,那么说明实际上这次DFS搜索到的是一条欧拉通路,那么结果还需额外+1,所以对所有奇数点DFS过后,得到的结果就是max{k/2,1}.…
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…
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…
题意:求一个图(不一定联通)最小额外连接几条边,使得可以一笔画出来 大致做法 1.找出联通块 2.统计每一个连通块里面度数为奇数的点的个数, 有一个性质 一个图能够用一笔画出来,奇数点的个数不超过2个 if  奇数点的个数==0  或者 ==1 直接找欧拉回路 else 将除去前面两个奇数点外的奇数点依次相连 然后找欧拉回路 然后记录路径 #include <cstdio> #include <cstring> #include <queue> #include <…
Machine Schedule Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1150 Description As we all know, machine scheduling is a very classical problem in computer science and has been studied for a very long history.…
Machine Schedule Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1150 Description As we all know, machine scheduling is a very classical problem in computer science and has been studied for a very long history.…
#include<cstdio> #include<cstring> ]; int find(int x) { if(visited[x]!=x) return find(visited[x]); return x; } void make(int a,int b) { int f1=find(a); int f2=find(b); if(f1!=f2) visited[f2]=f1; } int main() { ]; int n,m,i,j,x,y; while(scanf(&…