分析:这里使用树形DP做. 1.最小顶点覆盖做法:最小顶点覆盖 == 最大匹配(双向图)/2. 2.树形DP: dp[i][0]表示i为根节点,而且该节点不放,所需的最少的点数. dp[i][1]表示i为根节点,而且该节点放,所须要的最少的点数. dp[i][0]=sum(dp[son[i][j]][1]) 该点不放.则它的儿子节点必须都放,仅仅有这样之间的边才干够被覆盖. dp[i][1]=sum(min(dp[son[i][j]][0],dp[son[i][j]][1])) 该点放的话,则它…
d.一颗树,选最少的点覆盖所有边 s. 1.可以转成二分图的最小点覆盖来做.不过转换后要把匹配数除以2,这个待细看. 2.也可以用树形dp c.匈牙利算法(邻接表,用vector实现): /* 用STL中的vector建立邻接表实现匈牙利算法 效率比较高 处理点比较多的效率很高.1500的点都没有问题 */ #include<iostream> #include<stdio.h> #include<algorithm> #include<string.h>…
题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=106048#problem/B 题意:给出一些点相连,找出最小的点数覆盖所有的 用树形dp来解决 dp[i][0]表示i点不选,dp[i][1]表示i点选,dp[i][0] = sum{ dp[ son[i] ][1] }, // i不选,则i的子节点全选, dp[i][1] = sum { min( dp[ son[i] ][0], dp[ son[i] ][1] ) } +…
Description Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <= 500). The grid contains K asteroids (1 <= K <= 10,000), which are conveniently located at the lattice points of the…
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4616 这道题目数据可能比较弱,搜索都可以AC,但是不敢写,哎…… 搜索AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cstdlib> #include <cmath> #include <vecto…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1054 题目大意:给你一棵树,选取树上最少的节点使得可以覆盖整棵树. 解题思路: 首先树肯定是二分图,因为树可以奇偶分层,从而根据二分图染色的原理可以确定树是二分图.我们可以用染色法确定出两个集合求最大匹配,也可以将边补成双向的,然后将最大匹配/2. 代码: #include<iostream> #include<cstdio> #include<cstring> #incl…
Going Home Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2963    Accepted Submission(s): 1492 Problem Description On a grid map there are n little men and n houses. In each unit time, every…
http://acm.hdu.edu.cn/showproblem.php?pid=1054 Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8510    Accepted Submission(s): 4096 Problem Description Bob enjoys playing computer games, espec…
Asteroids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 17237   td>Accepted: 9375 Description Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <= 500). The grid contain…
Machine Schedule Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 11958   Accepted: 5094 Description As we all know, machine scheduling is a very classical problem in computer science and has been studied for a very long history. Scheduli…