Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. CEN112 Questions 2016 15-FE-5.
Laplacian Filter
In image processing, Laplacian filter is
used as sharpening spatial filter.
In a 2D array, the value of current position
is calculated as
D(i ,j) = 4 * D(i,j) - (Sum of 4 neighbors)
Assume that any neighbor of D(i,j)
which is out of border has the same value as
D(i,j).
Question:
You will be given a 2D array and then you will also be
given k coordinates. Show the values of cells on the given
k coordinates.
Hint: Do not change the value of the cell.
Input specification:
First, you will be given two integers: the height (n)
and width (m) of 2D matrix.
The following n lines contain m integers which are between
0 and 255. On the next line, you will be given one
integer (k). On the following k lines you will be given
(x,y) coordinates of k cells where 1 ≤ (n,m, and k) ≤ 100.
Output specification:
Show k integers.
Sample Input
5 5
2 6 6 6 1
5 4 6 3 4
1 6 2 5 4
3 2 3 7 4
3 4 1 1 7
3
2 2
1 5
4 4
|
Sample Output
-7
-1
15
|
Для отправки решений необходимо выполнить вход.
|