Tour de Byteotia
Time limit3sMemory limit128 MB
Block the fewest roads so no closed trail (no repeated road) passes through any of towns 1 to k.
- Level
Medium7 of 10
- Topics
- Graph, DFS, Greedy, Union-find
- Solved
- No attempts yet
Problem
There are towns in Byteotia. Some pairs of towns are joined by bidirectional roads. The roads meet only at their endpoints and never cross (a system of tunnels and flyovers makes this possible).
A famous bicycle race is about to be held. Its route follows some of the roads, starts and ends in the same town, and travels along each road at most once. In other words, the route is a closed trail that reuses no road.
Byteasar and his club friends dislike the race and want to keep it away from the towns where they live. Given the towns where the club members live, determine the minimum number of roads that must be blocked so that the race's route cannot pass through any of those towns.
Input
The first line contains three integers , , and (, , ), separated by single spaces: the number of towns, the number of roads, and the number of towns where club members live. The towns are numbered from to , and the towns where club members live are exactly those numbered from to .
Each of the next lines contains two integers and (), separated by a single space, meaning that towns and are joined by a bidirectional road. Every pair of towns is joined by at most one road.
Output
Print a single integer: the minimum number of roads that must be blocked so that the race's route cannot pass through any town where a club member lives.
Hint
