HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Unsorted > problem:


Connected components

Section problems

• Sign
• Timer
• Tickets
• find the numbers
• Flowers
• Flowchart 1
• Flowchart 2
• Flowchart 3
• Connected components
• Going to the Movies
• How many digits?
• How many divisors?
• Molecules
• Round numbers
• Tower of Happiness
• Workshop
• Wonder primes

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 1000/1000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.

Problem description

Calculate number of connected components in undirected graph.

Input

There is a single integer on the first line of input N (1 <= N <= 100), then N lines with N integers 0 or 1 (adjacency matrix of graph).

Output

Write number of connected components.

Example

stdin stdout

6

0 1 1 0 0 0
1 0 1 0 0 0
1 1 0 0 0 0
0 0 0 0 1 0
0 0 0 1 0 0
0 0 0 0 0 0

3

Для отправки решений необходимо выполнить вход.

www.contester.ru