eolymp
bolt
Try our new interface for solving problems
Problems

Number of hanging vertices 1

Number of hanging vertices 1

Given a simple undirected unweighted graph. Count the number of hanging vertices in it. The vertex is hanging, if its degree is $1$. \InputFile The first line contains number $n~(1 \le n \le 1000)$. The next $n$ lines contain the adjacency matrix. \OutputFile Print the number of hanging vertices in a graph. \includegraphics{https://static.e-olymp.com/content/a2/a2eef5c326fc869babcf1a5ea52db1e4384a0f5b.gif}
Time limit 3 seconds
Memory limit 128 MiB
Input example #1
2
0 1
1 0
Output example #1
2
Input example #2
3
0 1 1
1 0 1
1 1 0
Output example #2
0