Network Monitoring
Time limit1sMemory limit128 MB
Given several graphs, decide for each whether a vertex cover of size at most 10 exists.
- Level
Medium7 of 10
- Topics
- Graph, Backtracking, Brute force
- Solved
- No attempts yet
Problem
An organization wants to monitor every direct communication line in a computer network. Monitoring software can be installed on at most 10 host computers. For the software to work, every direct communication line A-B must have at least one monitored endpoint, either A or B.
For each network, determine whether it is possible to choose at most 10 hosts that cover every communication line.
Input
The input contains several network scenarios. Each scenario has the following format.
- The first line contains the number of hosts
n. (10 <= n <= 2500) - Then
nlines follow, one for each host. Hosts are named0, 1, ..., n-1. The first line describes the neighbors of host0, the second describes the neighbors of host1, and so on through hostn-1. - Each of these lines begins with an integer
d. (1 <= d < n) This is the number of hosts directly connected to that host. It is followed bydneighbor host numbers, separated by spaces and listed in increasing order. Every neighbor number is valid from0ton-1and is not the host itself.
The final line contains only 0. Do not process that line.
Output
Print one line for each network. Scenario numbers start at 1.
The format is Network n: yes or Network n: no, where n is the scenario number. Print yes if at most 10 hosts can be chosen to monitor every direct communication line; otherwise print no.