HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Linear Data Structures: Arrays > problem:


50990 - Two Neighbors

Guest
• Review clarifications (1)

Section problems

• 50445 - Cryptography
• 51246 - Swap largest word, reverse ...
• 50516 - Lines
• 50446 - Snake
• 50345 - Orders
• 50822 - Linked List
• 50529 - Row to Table
• 50499 - Table to Row
• 50990 - Two Neighbors
• 50823 - Secret Number
• 50853 - Parking Place
• 50496 - Falling Bricks
• 50876 - He is my cousin
• 50829 - Decode an Image
• 50851 - Repeated Numbers
• 50838 - Balanced Numbers
• 50515 - Lines - Revisited

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.

Two Neighbors

In a 2D matrix, you are given housing of n people where 1 represents the houses and 0 represents the empty places.

Question: Show the number of houses which have at least two neighbors.

Input specification: First, you will be given an integer: the size of 2D matrix (n). The following n lines contain n integers (one or zero) where 1 ≤ n ≤ 100.

Output specification: Show one integer.

Sample Input
5
0 1 0 0 1
1 1 0 0 1
0 0 1 0 1
1 0 0 1 0
1 1 0 0 1
Sample Output
3



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

www.contester.ru