Independent Cycles
Print the dimension of the graph's cycle space: the maximum number of independent cycles (equivalently, edges you must delete to make it a forest). Multi-edges and self-loops count.
Input: the first line has N and M; each of the next M lines has an edge u v.
Output: M − N + (number of components) — computed correctly for multigraphs.
Constraints:
- 1 ≤ N, M ≤ 105
Sample Tests
Input 1
4 5 1 2 2 3 3 1 3 4 4 4
Output 1
2
Input 2
2 1 1 2
Output 2
0
Discussion (opens after you solve — no spoilers before)
No comments yet.