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
|
Для отправки решений необходимо выполнить вход.
|