描述 Alice and Bob are walking in an ancient maze with a lot of caves and one-way passages connecting them. They want to go from cave 1 to cave n. All the passages are difficult to pass. Passages are too small for two people to walk through simultaneou…
时间限制:0.25s 空间限制:4M 题意: 在n(n<=400)个点的图中,找到并输出两条不想交的最短路.不存在输出“No sulotion”: Solution: 最小费用最大流 建图与poj 2135 一样,添加S到1的流量为2权为0,n到T的流量为2权为0的边,其它边的流量为1,权为路径长度. 但是这道题麻烦不在要输出最短路,而在仅仅4M的内存上. 由于只有4M,我们最多存上400*400条边.但是图却是一个无向图,朴素的想法是存上400*400*2条边,但是这里内存不够. 所以我们首先…
[原题](http://poj.org/problem?id=3068) 给一个有向带权图,求两条从0-N-1的路径,使它们没有公共点且边权和最小 . //是不是像传纸条啊- 是否可行只要判断最后最大流是不是2就可以了 #include<cstdio> #include<queue> #include<cstring> #define N 1010*1010 #define inf 0x3f3f3f3f using namespace std; int n,m,head…
题目求一张图两条边不重复的最短路. 一开始我用费用流做. 源点到1连容量2费用0的边:所有边,连u到v和v到u容量1费用cost的边. 总共最多会增广两次,比较两次求得的费用,然后输出路径. 然而死MLE不过.. 看了题解,是用最大流的做的. 源点到1连容量为2的边:然后把属于最短路的边都加进去,容量为1. 跑一遍最大流,如果流量为2,那就有解,最后再从1到n沿着满流的边输出两条路径. 学到了怎么求出所有属于最短路的边... #include<cstdio> #include<cstri…
题意:2个人从1走到n,假设一条路第一次走则是价值di,假设第二次还走这条路则须要价值di+ai,要你输出2个人到达终点的最小价值! 太水了!一条边建2次就OK了.第一次价值为di,第二次为ai+di,加入源点汇点跑最小费用最大流就OK了! AC代码: #include<iostream> #include<string> #include<algorithm> #include<cstdlib> #include<cstdio> #includ…
描述 When FJ's friends visit him on the farm, he likes to show them around. His farm comprises N (1 <= N <= 1000) fields numbered 1..N, the first of which contains his house and the Nth of which contains the big barn. A total M (1 <= M <= 10000)…
1506: Double Shortest Paths Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 49  Solved: 5 Description Input There will be at most 200 test cases. Each case begins with two integers n, m (1<=n<=500, 1<=m<=2000), the number of caves and passages.…
Double Shortest PathsAlice and Bob are walking in an ancient maze with a lot of caves and one-way passages connectingthem. They want to go from cave 1 to cave n. All the passages are difficult to pass. Passages are toosmall for two people to walk thr…
传送门:Double Shortest Paths 题意:有两个人:给出路径之间第一个人走所需要的费用和第二个人走所需要的费用(在第一个人所需的 费用上再加上第二次的费用):求两个人一共所需要的最小费用. 分析:建立超源和超汇,流量分别为2,从源点到汇点的最大流2时最小费用为答案. #include <cstdio> #include <cstring> #include <string> #include <queue> #include <cmat…
Farm Tour Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 17230   Accepted: 6647 Description When FJ's friends visit him on the farm, he likes to show them around. His farm comprises N (1 <= N <= 1000) fields numbered 1..N, the first of…