#P1041. [NOIP 2003 提高组] 传染病控制(疑似错题)
[NOIP 2003 提高组] 传染病控制(疑似错题)
Description
Studies show that this infectious disease has two very special properties.
First, its transmission routes form a tree. A person can only be infected by a specific person . As long as does not get sick, or the transmission route between and (i.e., ) is cut, will not get sick.
Second, the disease spreads periodically. Within one transmission period, it infects only one generation of patients, and does not spread further to the next generation in that period.
These properties greatly reduce the pressure on Penglai’s disease control efforts, and they have already obtained a potential transmission map (a tree) for part of the susceptible population. However, the problem is not over. Due to limited manpower and technology, during one transmission period they can cut only one transmission route. Any remaining, uncontrolled routes will cause more susceptible people to be infected (that is, people who are connected to the currently infected by a transmission route that has not been cut). When it becomes impossible for any healthy person to be infected, the disease stops spreading. Therefore, Penglai’s CDC must decide an order in which to cut transmission routes so that as few people as possible become infected.
Your program must, for the given tree, find an appropriate cutting order.
Input Format
The first line contains two integers and .
The next lines each contain two integers and , indicating there is an edge between nodes and (that is, there is a transmission route between person and person ). Node is already infected. The graph is a tree, so .
Output Format
One line: the total number of people who get infected.
7 6
1 2
1 3
2 4
2 5
3 6
3 7
3
Hint
Constraints: For of the testdata, .
Source: NOIP 2003 Senior, Problem 4.
Translated by ChatGPT 5
京公网安备 11011102002149号