Quarantine Station Placement
Time limit10sMemory limit512 MB
Place quarantine stations on the fewest islands so every liner touches a station, or report that K stations cannot cover all liners.
- Level
Medium7 of 10
- Topics
- Backtracking, Graph
- Solved
- No attempts yet
Problem
Your country declared a state of emergency because MOFU syndrome is spreading. Anyone who catches it cannot get out of bed in the morning. You are a programmer at the Department of Health, and you have to put a measure in place quickly.
The country has islands numbered from 1 to , and ocean liners run between some pairs of islands. The Department of Health decided to build quarantine stations on a few islands and stop infected people from travelling. For the plan to work, there must be no liner whose two endpoint islands both lack a quarantine station. The trouble is that the budget covers at most stations.
Decide whether such a placement exists. If it does, find the smallest number of quarantine stations it needs.
Input
The first line contains three integers , , and (, , ).
Each of the next lines contains two integers and (, ). This means the -th liner connects island and island . For every , , and at most one liner runs between any pair of islands.
Output
If no placement of quarantine stations satisfies the requirement, print Impossible. Otherwise print the smallest number of quarantine stations.