http://acm.hdu.edu.cn/showproblem.php?pid=3488 给一个无源汇的,带有边权的有向图 让你找出一个最小的哈密顿回路 可以用KM算法写,但是费用流也行 思路 1. 哈密顿回路对于每个点的流量有限制,因此$V$拆开为$V$和$V'$ 2. 我们建立附加源点$S$和附加汇点$T$哈密顿回路中的每个点有其唯一的后继和前驱,换句话说,对于任意一个点$V$,它满足$in(V)=out(V)$ 为了满足该条件,从源点向$V$ 连接容量为1,费用为0的边,从$V'$向汇…
Cyclic Tour Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/65535 K (Java/Others)Total Submission(s): 2399    Accepted Submission(s): 1231 Problem Description There are N cities in our country, and M one-way roads connecting them. Now L…
http://acm.hdu.edu.cn/showproblem.php?pid=3488 题意: 给出n个点和m条边,每条边有距离,把这n个点分成1个或多个环,且每个点只能在一个环中,保证有解. 思路: 把一个点分成两部分,1~n和n+i~2*n. 连边的情况是这样的,(src,i,1,0),(i+n,dst,1,0). 如果两个点之间相同,则(i,j+n,1,d). 其实这道题目就是选n条边,如何使得权值之和最小. 具体请参考这http://blog.csdn.net/u013480600…
题意:给定N个点,M条边,M >= N-1.已知M条边都有一个权值,已知前N-1边能构成一颗N个节点生成树,现问通过修改这些边的权值使得最小生成树为前N条边的最小改动总和为多少? 分析:由于计算的最小改动且为最小生成树则显然前N-1条边肯定权值都减少,后面的边权值都增加.由于选择的边为前N-1得到最小生成树,因此首先将N-1条边构图,然后对后面的每一条边,那么这条边所构成的环中,有任意一条边的a与该边b,设原始权重为w[a],w[b],改变量为d[a],w[b],则有w[a] - d[a] <…
Cyclic Tour Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/65535 K (Java/Others)Total Submission(s): 1197    Accepted Submission(s): 626 Problem Description There are N cities in our country, and M one-way roads connecting them. Now Li…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3790 Problem Description 给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费最少的.   Input 输入n,m,点的编号是1~n,然后是m行,每行4个数 a,b,d,p,表示a和b之间有一条边,且其长度为d,花费为p.最后一行是两个数 s,t;起点s,终点.n和m为0时输入结束.(1<n…
题目链接: http://poj.org/problem?id=1797 Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his customer has buil…
本题思路:最短路变形,改变松弛方式即可,dist存的是源结点到当前结点的最长路的最小权值. 参考代码: #include <cstdio> #include <cstring> #include <algorithm> #define INF 0x3f3f3f3f using namespace std; + ; , G[maxn][maxn], dist[maxn]; bool vis[maxn]; int Dijkstra(int source, int aid)…
传送门:http://poj.org/problem?id=3565 Ants Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 7650   Accepted: 2424   Special Judge Description Young naturalist Bill studies ants in school. His ants feed on plant-louses that live on apple tree…
传送门:http://poj.org/problem?id=2195 Going Home Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 26151   Accepted: 13117 Description On a grid map there are n little men and n houses. In each unit time, every little man can move one unit st…