UVALive - 6266 Admiral 题意:找两条完全不相交不重复的路使得权值和最小. 思路:比赛的时候时间都卡在D题了,没有仔细的想这题,其实还是很简单的,将每个点拆开,连一条容量为1,费用为0的边,起点和终点容量为2,两点之间有边就加一条容量为1,费用为权值的边,这样跑一边费用流就可以了. #pragma comment(linker, "/STACK:1000000000") #include <bits/stdc++.h> #define LL long l…
#include <iostream> #include <cstdio> #include <cmath> #include <queue> #include <cstring> using namespace std; const int maxm = 50000*4; const int maxn = 110; struct node { int v,cost,flow,next;//v表示指向的下一个顶点,a表示系数,flow表示可以过的…
Description There are N cities, and M directed roads connecting them. Now you want to transport K units ofgoods from city 1 to city N. There are many robbers on the road, so you must be very careful. Themore goods you carry, the more dangerous it is.…
Description In a country there are n cities connected by m one way roads. You can paint any of these roads. To paint a road it costs d unit of money where d is the length of that road. Your task is to paint some of the roads so that the painted roads…
Description A prominent microprocessor company has enlisted your help to lay out some interchangeable components(widgets) on some of their computer chips. Each chip’s design is an N × N square of slots. Oneslot can hold a single component, and you ar…
There will be several test cases in the input. Each test case will begin with a line with three integers: N A B Where N is the number of teams (1N1, 000), and A and B are the number of balloons in rooms A and B, respectively (0A, B10, 000). On each o…
题目地址:HDU 3667 这题的建图真是巧妙...为了保证流量正好达到k.须要让每一次增广到的流量都是1,这就须要把每一条边的流量都是1才行.可是每条边的流量并非1,该怎么办呢.这个时候能够拆边,反正c最多仅仅有5,拆成5条流量为1的边.可是这时候费用怎么办呢,毕竟平方的关系不能简单把每一条边加起来.这时候能够把拆的边的流量设为1,3,5,7,9.假设经过了3个流量,那就肯定会流1,3,5.费用为9,是3的平方,同理,其它的也是如此.然后依照给出的边建图跑一次费用流就能够了. 代码例如以下:…
题意:每个点i有\(s_i\)个人和\(b_i\)份食物,每个人都要找到一份食物.现在有M条有向边,从点i到点j,容量为c,第一次走过不要紧,从第二次开始就要承担\(p(0<p<1)\)的道路损坏的风险.题目保证每个人都能拿到食物,求这个风险的最小值. 分析:建立源点S和汇点T.从S到点i建容量为\(s_i\),费用为0的边;从点i到T建容量为\(b_i\),费用为0的边. 风险的最小值可以转化为求安全达成目标的. 则\(ans = \prod (1-p_i)^{k_i}\), 对ans取对数…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Apple Transportation Time Limit: 1 Second      Memory Limit: 32768 KB There's a big apple tree in the forest. In the tree there are N nodes (numbered from 0 to N - 1), and the nodes are conne…
题目链接: Coding Contest Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others) Problem Description A coding contest will be held in this university, in a huge playground. The whole playground would be divided into N blocks,…