Railway Tour
Time limit1sMemory limit512 MB
Given an undirected graph, find the minimum number of edge-disjoint trails needed to cover every edge exactly once.
- Level
Medium6 of 10
- Topics
- Graph, DFS, Math, Implementation
- Solved
- No attempts yet
Problem
Korea has N cities C1, C2, ..., CN, connected by M bidirectional railway lines between pairs of cities.
Gahee, who loves railways, wants to go on railway tours. A railway tour is a journey from a starting city to an ending city that uses only railway lines, without riding any single railway line more than once. The starting city and the ending city may be the same, and a city may be visited multiple times.
Gahee wants to ride every railway line exactly once using the minimum number of railway tours. Determine how many railway tours she must take.
Input
The first line of input gives two integers N (1 ≤ N ≤ 200,000) and M (1 ≤ M ≤ 300,000).
Each of the following M lines gives two distinct integers u, v (1 ≤ u, v ≤ N). This means a bidirectional railway line exists between Cu and Cv.
At most one railway line directly connects any pair of cities.
Output
Output the minimum number of railway tours Gahee must take.