#P17166. [CEOI 2026] Flower Cutting
[CEOI 2026] Flower Cutting
Problem Description
In the CEOI community garden, we are growing a collection of special flowers that tightly knit their roots together. If we cut them, they regrow, as long as we do not cut too aggressively and cause irreparable damage.
If a pair of flowers, and , knit their roots together, we call them "connected". Otherwise, they are "disconnected". Roots grow according to the following rule: Let and be two disconnected flowers. If at least other flowers and exist, such that each of and is connected with both and , then roots between and will grow, and they will become connected.
These flowers have now been growing for a while, and all the roots that could grow by following the above rule have grown. In other words, if two flowers and are both connected with some flowers and , then and are guaranteed to be connected with each other.
We need to uproot this garden and move it to the next CEOI location. To simplify the migration, we would like to cut as many roots as possible. However, we want the flowers to regrow back into their current state. What is the maximum number of connected pairs of flowers that we may cut so that they still regrow back into their current state? It does not matter how many iterations of growth it would take.
Input Format
The first line of the input contains two space-separated integers and , the number of flowers and the number of existing connections between them. This is followed by lines, each containing a pair of integers and , indicating that flowers and are connected. Flowers are marked with integers . The input is guaranteed to follow the rule described in the task description.
Output Format
Output a single integer - the maximum number of connections that we may cut.
9 14
1 2
1 4
1 5
2 4
2 5
3 4
4 5
3 6
4 6
6 7
6 9
7 9
8 9
5 8
2
Hint
Comment
The flowers in the example before any cutting. One can check that no additional connections can form based on the described growth procedure.
:::align{center}
:::
The flowers in the example after the cutting have connections less. The connection between and can regrow because flowers and are both connected to flowers and . Similarly, the connection between and can regrow because flowers and are both connected to flowers and .
:::align{center}
:::
Constraints
Subtasks
- Subtask ( points): and
- Subtask ( points):
- Subtask ( points): We guarantee that each flower is connected with at most other flowers.
- Subtask ( points): and
- Subtask ( points): No additional constraints.