So NP

3.7

78 votes
Algorithms, Easy, Graphs
Problem

Once a upon time a problem setter offered a problem to Arpa. Like always Arpa said "eaaasy", but after a time Arpa said this problem is so NP.

Solve this problem to prove Arpa is always right and his first opinion is correct.

You are given a graph with n nodes and m edges.
Calculate maximum number of edges that can be removed from the graph so that it contains exactly k connected components.


Input

The first line contains n,m,k(in order).
The next m lines have 2 number,ui and vi that showS there is an edge between those nodes.
It is guaranteed that input is valid(no multiple edges and no loops).

 

Output

Maximum number of edges that can be removed from the graph such that it contains exactly k connected components.
If the graph intially has more than k components print 1

 

Constraints

1n,m100 000
1kn

Sample Input
4 3 2
1 2
2 3
1 3
Sample Output
1
Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

Initially, the graph has 2 connected components, hence we can remove only 1 edge.

Editor Image

?