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

建议使用的浏览器:

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

5067:Harry And Dig Machine

题目描述
  As we all know, Harry Porter learns magic at Hogwarts School. However, learning magical knowledge alone is insufficient to become a great magician. Sometimes, Harry also has to gain knowledge from other certain subjects, such as language, mathematics, English, and even algorithm.
  Dumbledore, the headmaster of Hogwarts, is planning to construct a new teaching building in his school. The area he selects can be considered as an n*m grid, some (but no more than ten) cells of which might contain stones. We should remove the stones there in order to save place for the teaching building. However, the stones might be useful, so we just move them to the top-left cell. Taking it into account that Harry learned how to operate dig machine in Lanxiang School several years ago, Dumbledore decides to let him do this job and wants it done as quickly as possible. Harry needs one unit time to move his dig machine from one cell to the adjacent one. Yet skilled as he is, it takes no time for him to move stones into or out of the dig machine, which is big enough to carry infinite stones. Given Harry and his dig machine at the top-left cell in the beginning, if he wants to optimize his work, what is the minimal time Harry needs to finish it?
输入解释
They are sever test cases, you should process to the end of file.
For each test case, there are two integers n and m.$(1 \leq n, m \leq 50)$.
The next n line, each line contains m integer. The j-th number of $i_{th}$ line a[i][j] means there are a[i][j] stones on the $j_{th}$ cell of the $i_{th}$ line.( $0 \leq a[i][j] \leq 100$ , and no more than 10 of a[i][j] will be positive integer).
输出解释
For each test case, just output one line that contains an integer indicate the minimal time that Harry can finish his job.
输入样例
3 3
0 0 0
0 100 0
0 0 0
2 2
1 1
1 1
输出样例
4
4
来自杭电HDUOJ的附加信息
Recommend heyang

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

题目来源 BestCoder Round #14

源链接: HDU-5067

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

共提交 0

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