上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 61 下一页
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2354思路:初始化step[][]==inf,然后如果当前点p.step<step[p.x][p.y],则入优先队列。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<queue> 6 using namespace std; 7 #define inf 1<<30 8 struct N 阅读全文
posted @ 2013-06-03 11:09 ihge2k 阅读(645) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2819思路:有矛盾关系的可以考虑二分匹配= =只交换行或者只交换列都能得到目的,如果不能,就输出-1。建图的时候应该建有向图。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<cmath>[ 6 using namespace std; 7 #define MAXN 111 8 int n,x; 9 in 阅读全文
posted @ 2013-06-03 09:51 ihge2k 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2831思路:按剩余时间排序即可,简单贪心。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 #define MAXN 111 7 struct Node{ 8 int v,d,index; 9 }node[MAXN];10 int n,t;11 bool flag;12 13 int cm 阅读全文
posted @ 2013-06-03 08:46 ihge2k 阅读(175) 评论(0) 推荐(0) 编辑
摘要: = =总感觉时间过的很快,总感觉训练的时间不够,然后就是= =毫无疑问的被虐==弱爆了有木有从湖南邀请赛华丽地打了个酱油回来,到今天的校赛,差点又要打酱油了.......归根到底还是缺乏锻炼,缺少经验,不过最最重要的还是教练说的那样:你们做的题还是太少了==弱爆了。从去年寒假正式踏上acm生涯到如今也差不多5个月左右的时间,虽然平时都在努力训练,但是acm真的是一条漫长而又艰辛的道路,目前为止还有好多重要的算法还不熟练,图论方面的知识也还有好多东西要补,有些高级数据结构方面的内容一直拖着不去搞= =于是今天就被线段树坑了= =hh大牛博客上的线段树题集很早以前就看了,但是也就是做了几道入门题= 阅读全文
posted @ 2013-06-02 21:06 ihge2k 阅读(243) 评论(2) 推荐(1) 编辑
摘要: 题目链接: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) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2236思路:引:为了保证每行每列只取一个元素,我们可以从二分图最大匹配的思想入手,把行和列分别看做二分图左右两部分,i-j的边权就是第i行第j列的元素的值。这样构图之后,求得的二分图最大匹配的4条边就是不在同行或同列的4个元素。有了这个思想时候,我们只需要再保证4个元素中最大值与最小值之差尽量小就可以了,于是我们可以二分枚举最大值与最小值之差,并枚举边权值的下界,如果枚举到某个边权值的下界时该图存在最大匹配,那么就更新max,否则就更新min。 1 #include<iostream> 阅读全文
posted @ 2013-05-31 21:55 ihge2k 阅读(522) 评论(0) 推荐(0) 编辑
上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 61 下一页