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

建议使用的浏览器:

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

3312:Seashells

题目描述
Bob lived on an island which has many kinds of beautiful seashells. We can regard this island as a rectangular grid that is n rows by m columns. Assume that the coordinates of the j-th column of the i-th row is (i, j). The coordinates of Bob's house is (x, y). There is at most one kind of seashells in each cell. Bob likes collecting seashells very much. However, he can only go the place of coordinates (x0, y0) with |x0-x|+|y0-y|<=A and max(|x0-x|, |y0-y|) <= B. How many kinds of seashells can Bob get at most?
输入解释
The first line contains the number T of test cases (T<=5). The first line of each test cases contains four integer numbers n, m, x and y (1<=x<=n<=1000, 1<=y<=m<=1000). The following n lines each containing m integers indicating the type of the seashells. The seashells are different if and only if the corresponding integers are different. The next line contains a single integer q (q <= 105) indicating the number of queries. Each of the following q lines contains two integers A and B(0<=A,B<1000).
输出解释
For each queries, output a single line contains a single integer indicating the number of seashells Bob can get.
输入样例
1
4 4 1 2
1 2 3 4
3 2 1 4
5 3 2 654321
2 3 4 6
4
2 1
1 0
3 2
999 999
输出样例
3
1
5
7
来自杭电HDUOJ的附加信息
Author hanshuai@WHU
Recommend wxl

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

源链接: HDU-3312

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

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 65536/65536K(Java/Others)