HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Linear Data Structures: Arrays > problem:


50990 - Two Neighbors

Guest
• Review clarifications (1)

Section problems

• 50345 - Orders
• 51127 - Maze solver
• 50822 - Linked List
• 51126 - Dr. Fllanxha
• 50529 - Row to Table
• 50499 - Table to Row
• 50823 - Secret Number
• 50853 - Parking Place
• 50990 - Two Neighbors
• 50496 - Falling Bricks
• 51021 - Number of Nodes
• 50829 - Decode an Image
• 51044 - Number of Trees
• 50876 - He is my cousin
• 51098 - Rotate a matrix
• 50838 - Balanced Numbers
• 50851 - Repeated Numbers

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