ACM: 图论题 poj 3308 最大流问题
来源:互联网 发布:win7如何安装linux系统 编辑:程序博客网 时间:2024/05/17 15:19
It is year 2500 A.D. and there is a terrible war between theforces of the Earth and the Mars. Recently, the commanders of theEarth are informed by their spies that the invaders of Mars want toland some paratroopers in the m × n grid yard of onetheir main weapon factories in order to destroy it. In addition,the spies informed them the row and column of the places in theyard in which each paratrooper will land. Since the paratroopersare very strong and well-organized, even one of them, if survived,can complete the mission and destroy the whole factory. As aresult, the defense force of the Earth must kill all of themsimultaneously after their landing.
In order to accomplish this task, the defense force wants toutilize some of their most hi-tech laser guns. They can install agun on a row (resp. column) and by firing this gun all paratrooperslanded in this row (resp. column) will die. The cost of installinga gun in the ith row (resp. column) of the grid yard isri (resp. ci ) and the totalcost of constructing a system firing all guns simultaneously isequal to the product of their costs. Now, your team as a high rankdefense group must select the guns that can kill all paratroopersand yield minimum total cost of constructing the firing system.
Input
Input begins with a number T showing the number of testcases and then, T test cases follow. Each test case beginswith a line containing three integers 1 ≤ m ≤ 50 , 1 ≤n ≤ 50 and 1 ≤ l ≤ 500 showing the number of rows andcolumns of the yard and the number of paratroopers respectively.After that, a line with m positive real numbers greater orequal to 1.0 comes where the ith number isri and then, a line with n positive realnumbers greater or equal to 1.0 comes where the ith numberis ci. Finally, l lines come eachcontaining the row and column of a paratrooper.
Output
For each test case, your program must output the minimum totalcost of constructing the firing system rounded to four digits afterthe fraction point.
Sample Input
1
4 4 5
2.0 7.0 5.0 2.0
1.5 2.0 2.0 8.0
1 1
2 2
3 3
4 4
1 4
Sample Output
16.0000
题意: 地球和火星发生战争, 火星派特工来偷袭地球的武器, 因为火星特工很厉害, 只要一个
解题思路:
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <queue>
using namespace std;
#define MAX 1005
const int INF = (1<<29);
int n, m, L, p[MAX];
double cap[MAX][MAX], flow[MAX][MAX], a[MAX];
int start, end, M;
inline double min(double a, double b)
{
}
void readGraph()
{
}
double KM(int start, int end)
{
}
int main()
{
//
}
- ACM: 图论题 poj 3308 最大流问题
- ACM: 最大流问题 图论题 poj 2263
- ACM: 最小费用最大流 图论题 poj 2…
- ACM: 最大流 图论题 poj 1797
- ACM: 图论题 poj 1149 网络流问题
- ACM: 最小费用用最大流 图论题 poj…
- ACM: 二分图最大匹配 图论题 poj 2…
- ACM: 图论题 poj 1466 最大独立团
- ACM: 图论题 poj 2240 (floyd + ST…
- ACM: 图论题 poj 1135
- ACM: 图论题 poj 3…
- ACM: 图论题 poj 1…
- ACM: 图论题 poj 1…
- ACM: 二分法 数论题 poj 1905
- ACM: 匈牙利算法 图论题 poj 3041 …
- ACM: 差分约束 图论题 poj 2983 sp…
- ACM: 有向欧拉图 图论题 poj 1386 …
- ACM: 图论题 poj 3177 同 3352
- ACM: 图论题 poj 2186 强连通分量
- ACM: 图论题 poj 3352 双连通题
- ACM: 图论题 poj 3177 同 3352
- Android的自定义控件起步
- dos批处理中%~dp0%的说明
- ACM: 图论题 poj 3308 最大流问题
- ACM: 搜索题 poj 1020
- ACM: 图论题 poj 1201 差分约束
- ACM: 图论题 poj 1149 网络流问题
- ACM: 图论题 poj 1236 强连通
- ACM: 图论题 poj 1275 差分约束题
- 图论: 差分约束系统
- ACM: 图论题 poj 1…
- ACM: 图论题 poj 1466 最大独立团