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

建议使用的浏览器:

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

4721:Food and Productivity

题目描述
In the Game Civilization X, the world is made up of square-shaped "tiles", forming a rectangle on the world map. For a tile located at row X and column Y , we give it a coordinate, say (X, Y ).
As you can see, different tiles have different "terrain-types", so they may have different amount of Resources. In this problem, we only consider two of them: Food and Productivity.
An important step in the Game is building cities. After you choose a tile to build a city, the Food amount in that tile will increase by A, and the Productivity amount will increase by B, no other tiles will be changed.
You decide to build your first city on the map, as an experienced player, you will choose the best tile on the map, here is how you make up your mind:
For each tile (X, Y ), you set up an "Influence Range" of that tile. Each tile (xi, yi) is said to be within the range if the following equation holds:
max(|X - xi| , |Y - yi|) <= R

After checking all the tiles within that range, you will get two values: the sum of all those tiles' Food amount, and the sum of all those tiles' Productivity. Among those two values, the final score for tile (X, Y ) will be the smaller one.
When choosing tiles, you just choose the tile with the highest score to build your city.
You are given a map with size N * M, and you wonder, for different values of A and B, what is the highest score for your first city?
输入解释
The first line has a number T (T <= 10) , indicating the number of test cases.
For each test case, first line has four numbers N, M, R and Q (1 <= N, M <= 500, 0 <= 2 * R + 1 <= min(N,M), Q <= 200000), which is the size of the map.
Then come N lines each with M numbers, they are the original Food (0 < Food <= 3) amount for each tile.
Then come N lines each with M numbers, they are the original Productivity
(0 < Productivity <= 3) amount for each tile.
Then come Q lines each with two numbers A and B (0 <= A, B <= 106). Each is a query for you to answer. Those queries will not affect each other.
输出解释
For test case X, output \Case #X:" first, in a single line.
Then output Q lines, each with an answer.
There should be a blank line *BETWEEN* each test case.
输入样例
1
3 3 0 2
1 2 1
1 1 1
1 1 1
1 1 1
1 2 1
1 1 1
1 2
2 1
输出样例
Case #1:
3
3
来自杭电HDUOJ的附加信息
Recommend zhuyuanchen520

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

源链接: HDU-4721

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

共提交 0

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