LearnPy Hub
← Arena
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
solution.py
Output appears here
Cities and Provinces · Python Arena problem · LearnPy Hub