HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


50988 - Laplacian Filter

Guest
• Review clarifications (1)

Volume problems

• 50987 - Very Looong Queue
• 50913 - Manhattan Distance
• 51008 - Sum of Regional Maxes
• 50729 - Max number in 2D array
• 50981 - Top popular m-students
• 51014 - Nine Men's Morris game
• 50743 - Total Scholarships Discount
• 50740 - Service Time - 1
• 50988 - Laplacian Filter
• 50747 - Safe boxes against thieves
• 50742 - King Arthur II
• 50928 - War Of Battleships
• 50930 - Tom and Jerry
• 50925 - Optimizing Elevator Usage
• 50791 - Mine field
• Trip to Librazhd
• 50912 - Trip to Librazhd

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

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



Для отправки решений необходимо выполнить вход.

www.contester.ru