Trees

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

Input

As usual.
N ≤ 1000.

Output

The minimum number of edges you have to remove.

Sample Input

3
0 1 1
1 0 1
1 1 0

Sample Output

1

All Submissions
Best Solutions


Point Value: 10
Time Limit: 2.00s
Memory Limit: 16M
Added: Jun 28, 2013

Problem Types: [Show]

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

The question states that there can be a forest of trees, does that mean a node with no indegrees and outdegrees counts as a tree in itself, because it still has the properties of a tree (n-1 edges, no cycle, all points strongly connected)

Would this:
http://imgur.com/gBmIAi4
be an accurate explanation for the input/ output, assuming a blank is a wildcard or am I completely lost? The problem is pretty vague so I need a bit of clarification.

You are lost...

Okay, I know it was simplistic though I figured I should try the most simple thing first. I tried googling it again and it seems to be much more complicated, thanks for telling me though.

u wot m8