当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3616:Escape From Huarong Road

题目描述
The Chibi Battle is perhaps the most famous battle in the history of China. Liu Bei and Sun Quan won the battle after using a series of wonderful stratagem. Now, they are going to catch the leader of their enemy Cao Cao.

In order to help Cao Cao to escape, the soldiers of Cao Cao have been divided into several parts, and Cao Cao is in one of these part. Now they are all in a rectangle area which can be divided into many squares of the equal size. Once the soldiers get out of this area, they escape successfully.

Because Liu Bei and Sun Quan don't know exactly which part Cao Cao is in, so they all Cao Cao's soldiers.

In this area, some squares are lawns that can be passed, while some squares are Marshes that can't be passed. Liu Bei and SunQuan decide to set fire on lawns to those squares can't be passed. Because some reasons, set fire on different squares needs different length of time. And they can only set fire on one square at the same time. Now, Cao Cao and all his soldiers are having rest and you can assume that they won't move. Liu Bei and SunQuan want to know how much time they need at least to set fire to make Cao Cao and all his soldiers can't escape any way when they want to move. Can you help them?

输入解释
The first line in the input file is a single integer: T (1 ≤ T ≤ 10), representing the number of test cases. For each test case, in the first line there are two integers: r and c (1 ≤ r, c ≤ 30) - the height and length of the area. Then there are r lines, in each line there are c integers. The j-th integer in the i-th line is mij. Each of these integers describes a square: if tij is positive, then the square is a lawn and it needs mij unit of time to set fire on it; if mij is 0, it means some soldiers of Cao Cao are having rest in this square; if mij is -1, means the square can't be passed.

When Cao Cao and his soldiers move, they can only move to a square that share an edge with the square they are in just now. All positive integers in the input file are smaller or equal to 100.
输出解释
For each test case, output a single integer, means the number of unit of time Liu Bei and Sun Quan need to set fire so that Cao Cao and his soldiers can't get escape.

It is guaranted that the answer is exists.

输入样例
1
4 3
1 2 1
1 10 1
1 0 -1
1 1 1
输出样例
6
来自杭电HDUOJ的附加信息
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3616

最后修改于 2020-10-25T23:05:17+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)