Graph Contest 2 P3 - Trees

View as PDF

Submit solution

Points: 7
Time limit: 1.0s
Memory limit: 16M

Problem type

Given: an undirected graph.
How many edges must you remove to make it a tree? (Or a forest of trees?)

Input Specification

N \le 1\,000, the number of vertices.
An adjacency matrix, N rows with N numbers (0 or 1).
The matrix will be symmetrical (it is undirected!).

Output Specification

The minimum number of edges you have to remove.

Sample Input

3
0 1 1
1 0 1
1 1 0

Sample Output

1

Comments

There are no comments at the moment.