摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4311思路:只会最简单的暴力枚举,枚举n/2的附近点即可。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define MAXN 100010 8 typedef long long ll; 9 #define inf (1ll)n?n:n/2+333);43 for(int i=st;i<=ed;i++){44 ll ans=Solve(i);45 ... 阅读全文
posted @ 2013-06-01 22:02 ihge2k 阅读(270) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4296题意:有 n 个地板,每个地板 i 有两个权值 Wi, Si,且 PDV(i) =(ΣWj) - Si ( j 表示在 i 上面的地板)。问如何调整顺序,使得【max(PDV)】最小。思路:假设i,j相邻,并且i上面的重量为sum,若i在上面,则有pi=sum-si,pj=sum+wi-sj;若j在上面,则有pi'=sum+wj-si,pj'=sum-sj;显然有pi<pi',pj>pj',于是令pj<pi',就有sum+wi-sj&l 阅读全文
posted @ 2013-06-01 21:00 ihge2k 阅读(312) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4313思路:初始时一条边都不加,将所有边按权值从大到小排序,判断每一个边两端的顶点是否是均为machine节点,如果是则应删除这条边(即sum要加上这条边的权值),否则加入这条边,然后在并查集合并时尽量让根节点为machine节点。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 #def 阅读全文
posted @ 2013-06-01 16:46 ihge2k 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3335思路:有矛盾的条件一般都应该往匹配这方面想:能够整除的连边,于是答案(最小路径)==|顶点个数|-最大匹配。这儿要注意的地方就是要去掉相同的数(排序一下即可),然后就是hungry算法搞定就可以了。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<vector> 6 using namespace 阅读全文
posted @ 2013-06-01 13:55 ihge2k 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3861思路:缩点是显然的:What’s more, for each pair of city (u, v), if there is one way to go from u to v and go from v to u, (u, v) have to belong to a same state.然后就是建新图了,求最大匹配即可。这里有最小路径覆盖==|顶点个数|-最大匹配; 1 #include<iostream> 2 #include<cstdio> 3 #incl 阅读全文
posted @ 2013-06-01 13:43 ihge2k 阅读(248) 评论(0) 推荐(0) 编辑