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

建议使用的浏览器:

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

3865:A Hard Journey

题目描述
ChenX was taken away by the arch devil, so the sharp shooter Brother Zheng was going to rescue him. The enemy’s army was distributed in an N * N grid, and each grid also can be divided in M * M small grids.

Brother Zheng's army has two kinds of attack form : from top to bottom, or from left to right. The weapon they use is Break-Cloud arrow, so each arrow will cost P fighting strength to eliminate a row or a column enemies in a big grid.

Notice that they can change the attack form at any time, and when they once change their attack form, they will use Q fighting strength.

The initial position of Brother Zheng is at the top-left corner, and ChenX was locked by arch devil at the right-bottom corner. When once make a move, Brother Zheng should eliminate all the enemies in the current big grid. If the current attack form is from top to bottom, then they can move onto the right grid of the big grid; if the current attack form is from left to right, then they can move onto the bottom grid of the big grid. The initial attack form can be either of the two.

Now Brother Zheng want to know how much the least fighting strength is so that can rescue ChenX.

For the case as the followed picture, N = 2, M = 3, P = 2, Q = 1.
Brother Zheng choices to start with the attack form: from top to bottom. It takes P * 1 fighting strength to eliminate all the enemies at grid[1][1]. Then Brother Zheng changed attack form to “from left to right” using Q fighting strength, and moved to the bottom grid[2][1]. To eliminate all the enemies, it takes P * 2 fighting strength. Then Brother Zheng changed attack form to ”from top to bottom” using Q fighting strength, and moved to the right grid[2][2], after used P * 3 fighting strength to eliminate this grid, ChenX was rescue with P * 1 + Q + P * 2 + Q + P * 3 = 14 fighting strength.
输入解释
For each case, the first line contains 4 integers: N, M, P, Q(0 < N <= 20, 0 < M <= 15, 0 <= P <= 20, 0 <= Q <= 20), the next N * N blocks, each block contains M * M matrixes, rows first.
输出解释
For each case, output one integer which indicates the least fighting strength.
输入样例
2 3 2 1
0 0 1
0 0 1
0 0 1
1 1 1
1 1 1
1 1 1
0 1 1
0 0 0
1 1 1
1 0 0
0 1 0
0 0 1
1 3 3 1
0 0 1
0 0 1
1 1 1
输出样例
14
7
来自杭电HDUOJ的附加信息
Recommend lcy

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

源链接: HDU-3865

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

共提交 0

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