Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Appoint description: System Crawler (2014-10-14)
Description
It is year 2500 A.D. and there is a terrible war between the forces of the Earth and the Mars. Recently, the commanders of the Earth are informed by their spies that the invaders of Mars want to land some paratroopers in the m × n grid yard of one their main weapon factories in order to destroy it. In addition, the spies informed them the row and column of the places in the yard in which each paratrooper will land. Since the paratroopers are very strong and well-organized, even one of them, if survived, can complete the mission and destroy the whole factory. As a result, the defense force of the Earth must kill all of them simultaneously after their landing.
In order to accomplish this task, the defense force wants to utilize some of their most hi-tech laser guns. They can install a gun on a row (resp. column) and by firing this gun all paratroopers landed in this row (resp. column) will die. The cost of installing a gun in the ith row (resp. column) of the grid yard is ri (resp. ci ) and the total cost of constructing a system firing all guns simultaneously is equal to the product of their costs. Now, your team as a high rank defense group must select the guns that can kill all paratroopers and yield minimum total cost of constructing the firing system.
Output
For each test case, your program must output the minimum total cost of constructing the firing system rounded to four digits after the fraction point.
题意:给出火星人降落的坐标(行x,列y)和使用每一行每一列武器的代价,你能够在一行或一列使用一把武器,能够消灭掉该行或该列的全部外星人。使用多种武器的代价是他们的乘积,你须要求出消灭全部火星人的最小代价。 思路:在把乘机转化成对数相加的形式,能够看到要消灭一个外星人,要么在他所在的行上放一把武器,要么在他所在列上放一把武器,因此能够在源点s和行x上连一条log(w)的边,在列和汇点t上连一条log(w)的边,在外星人的坐标x和y+n之间连一条INF的边。由于增广的时候满足流量限制所以会选择最小的代价。
只是还是wa了非常久。。原因就是用个g++提交,输出的时候使用了%lf,后来改成%f了还是wa,后来发现关闭了c++和c的输入输出同步,但任然在混用输入。。取消关闭之后就ac了。。。所以建议没事还是不要混用输入输出了
代码例如以下:
/************************************************************************* > File Name: c.cpp > Author: acvcla > QQ: > Mail: acvcla@gmail.com > Created Time: 2014年10月13日 星期一 22时26分17秒 ************************************************************************/#include #include #include #include #include #include