POJ 3398 / UVA 1218 Perfect Service 树形DP

A network is composed ofNcomputers connected byN 1 communication links such that any two computers can be communicated via a unique route. Two computers are said to beadjacentif there is a communication link between them. Theneighborsof a computer is the set of computers which are adjacent to it. In order to quickly access and retrieve large amounts of information, we need to select some computers acting asserversto provide resources to their neighbors. Note that a server can serve all its neighbors. A set of servers in the network forms aperfect serviceif every client (non-server) is served byexactly oneserver. The problem is to find a minimum number of servers which forms a perfect service, and we call this numberperfect service number.

We assume thatN(≤ 10000) is a positive integer and theseNcomputers are numbered from 1 toN. For example, Figure 1 illustrates a network comprised of six computers, where black nodes represent servers and white nodes represent clients. In Figure 1(a), servers 3 and 5 do not form a perfect service because client 4 is adjacent to both servers 3 and 5 and thus it is served by two servers which contradicts the assumption. Conversely, servers 3 and 4 form a perfect service as shown in Figure 1(b). This set also has the minimum cardinality. Therefore, the perfect service number of this example equals two.

Your task is to write a program to compute the perfect service number.

,明天是世上增值最快的一块土地,因它充满了希望

POJ 3398 / UVA 1218 Perfect Service 树形DP

相关文章:

你感兴趣的文章:

标签云: