摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2242思路:Tarjan求边双连通分量,进行缩点后成树,然后就是树型dp,求一下最小差值就行了。ps:注意点:由于双向建边,DP搜索时要记录父亲,只能往下搜,不能搜该节点的父亲。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<stack> 6 #include<vector> 7 using 阅读全文
posted @ 2013-06-04 21:32 ihge2k 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2732思路:如果从某一根柱子能够直接跳到迷宫的外面,那么我们就将这个点连接到汇点。对于哪些不能跳出去但是又有柱子的点,那么 我们就去按照跳跃距离搜寻有没有其他的柱子能够去跳跃,如果能够找到的话,那么连接这两点,并且将容量控制为弧尾节点的柱子数,也正是由于一条弧只能够约 束一个顶点,所以我们需要进行拆点,点内之间流量为本身柱子数。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #inclu 阅读全文
posted @ 2013-06-04 16:54 ihge2k 阅读(549) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1827思路:缩点后建新图,然后找入度为0的点,在入度为0的点中找颜色相同的最小的花费,将这些花费相加就是最后最小的花费了。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<vector> 6 #include<stack> 7 using namespace std; 8 #define MA 阅读全文
posted @ 2013-06-04 14:24 ihge2k 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4463思路:由于nike与apple必须有直接的边相连,因此可以先把这条边选进去,然后就是Kruskal求最小生成树了,由于一开始已经把点nike和点apple合并了,因此kruskal选择边的时候就不会选进去了。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<cmath> 6 using namesp 阅读全文
posted @ 2013-06-04 10:58 ihge2k 阅读(388) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3665思路:对海相邻的点进行标记即可,然后就是裸的最短路了。 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 bool mark[22]; 9 bool visited[22];10 int 阅读全文
posted @ 2013-06-04 09:29 ihge2k 阅读(243) 评论(0) 推荐(0) 编辑