IntermediateRating 1300
Cities and Provinces
An n×n 0/1 matrix says which cities are directly connected. Print the number of provinces (connected groups).
Input
n, then n lines.
Output
A count.
Sample 1
Input
3 1 1 0 1 1 0 0 0 1
Output
2
Sample 2
Input
3 1 0 0 0 1 0 0 0 1
Output
3
Output appears here