时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 65536K,其他语言131072K
64bit IO Format: %lld
题目描述
In GGO, a world dominated by gun and steel, players are fighting for the honor of being the strongest gunmen. Player Shino is a sniper, and her aimed shot kills one monster at a time. Now she is in an n*n map, and there are monsters in some grids. Each monster has an experience. As a master, however, Shino has a strange self-restrain. She would kill at most one monster in a column, and also at most one in a row. Now she wants to know how to get max experience, under the premise of killing as many monsters as possible.
输入描述
The first line contains an integer $n$.
$n<=500$
Then $n$ lines follow. In each line there are $n$integers, and $A_{ij}$ represents the experience of the monster at grid $(i,j)$.
If $A_{ij}=0$, there is no monster at grid $(i,j)$.
The experience is the minimal experience of all the monster which are killed.
It guaranteed that the maximum of the experience of the monster is not larger than $10^9$
输出描述
One integer, the value of max experience.
示例1
输入
2
2 0
1 8
输出
2
题目链接:B.Bullet
退役之后图论没怎么做了,只记得最短路了23333,实际是个简单题,很显然的网络流,考虑一行一列最多只能放一个,因此把行和列拿出来当做点,设源点为$S$,汇点为$T$,先把最低经验值设为$1$,跑一遍最大流得到最坏情况下的最多杀怪数,然后二分最小的经验值,每次选出大于等于当前假设经验值的怪物,重新建图跑最大流。
建图如下:
- 对所有行建边:$(S,i,\infty)$
- 对所有列建边:$(j+n,T,\infty)$
- 如果位置$(i,j)$有怪物且其血量大于,则建边:$(i, n+j,1)$
代码:
1 |
|