HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Linear Data Structures: Arrays > problem:


50988 - Laplacian Filter

Guest
• Review clarifications (1)

Section problems

• 50531 - File Decryption
• 51012 - Palindrome-k
• 50469 - Letter Grades
• 50525 - Ordering Pizza
• 51099 - Mr. Monk
• 50468 - Draw Matrix - 2
• 51096 - Guess the number - 2
• 50448 - Paint Buckets
• 50988 - Laplacian Filter
• 50269 - Matrix Determinant
• 50986 - The Oldest Person
• 50925 - Optimizing Elevator Usage
• 51173 Question 5
• 50334 - What is the class average?
• 50873 - Max Frequency
• 51009 - Sum of the nth row
• ECE - Question 1

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