Social Network Vaccinations
Time limit2sMemory limit128 MB
Given a graph with n at most 30 and D at most 6, choose D vertices to vaccinate so that the largest connected component remaining is as small as possible.
- Level
Medium7 of 10
- Topics
- Graph, Brute force, DFS, Combinatorics
- Solved
- No attempts yet
Problem
Health-care policy decisions lead to many interesting computational questions, and one of them concerns vaccinations. Leaving the decision to each individual assumes that only the vaccinated person benefits. That is far from the truth: a vaccinated person can neither catch nor transmit the disease, so they also help protect everyone around them. From society's point of view, it is therefore best to choose carefully who gets vaccinated.
We model this as follows. We are given a social network (a graph) of individuals and their friendships. Whenever someone gets sick, they infect all of their unvaccinated friends, who then spread the disease in the same way. A vaccinated person never gets sick. We have doses of the vaccine, so we may vaccinate individuals. After vaccinating, we pessimistically assume that the disease breaks out at a single individual, and that this starting point is chosen so as to maximize the number of people who eventually get sick. Our goal is to choose the individuals to vaccinate so that this worst-case number of sick people is as small as possible. Report that minimum.
Input
The first line contains the number of data sets. Then follow the data sets, each in the following form.
The first line of a data set contains two integers and , where is the number of people in the network and is the number of vaccine doses available. People are numbered from to .
This is followed by lines; the -th of them lists all friends of person , separated by spaces. Friendship is reflexive and symmetric: everyone is at least their own friend, and if is a friend of , then is a friend of .
Output
For each data set, first print Data Set x: on a line by itself, where is the data set's number (starting from ). On the next line, print the number of people who get sick in the worst case when the vaccinated individuals are chosen optimally. Put one blank line between consecutive data sets.