Submit | All submissions | Best solutions | Back to list |
NETADMIN - Smart Network Administrator |
The citizens of a small village are tired of being the only inhabitants around without a connection to the Internet. After nominating the future network administrator, his house was connected to the global network. All users that want to have access to the Internet must be connected directly to the admin's house by a single cable (every cable may run underground along streets only, from the admin's house to the user's house). Since the newly appointed administrator wants to have everything under control, he demands that cables of different colors should be used. Moreover, to make troubleshooting easier, he requires that no two cables of the same color go along one stretch of street.
Your goal is to find the minimum number of cable colors that must be used in order to connect every willing person to the Internet.
Input
t [the number of test cases, t<=500]
n m k [n <=500 the number of houses (the index of the admin's house is 1)]
[m the number of streets, k the number of houses to connect]
h1 h2 ... hk [a list of k houses wanting to be conected to the network, 2<=hi<=n]
[The next m lines contain pairs of house numbers describing street ends]
e11 e12
e21 e22
...
em1 em2
[next cases]
Output
For each test case print the minimal number of cable colors necessary to make all the required connections.
Example
Input: 2 5 5 4 2 3 4 5 1 2 1 3 2 3 2 4 3 5 8 8 3 4 5 7 1 2 1 8 8 7 1 3 3 6 3 2 2 4 2 5 Output: 2 1Warning: large Input/Output data, be careful with certain languages
Added by: | Tomasz Niedzwiecki |
Date: | 2005-01-23 |
Time limit: | 4.072s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | C C++ 4.3.2 CPP JAVA |
Resource: | DASM Programming League 2004, problemset 6 |
Public source code since: | 2013-05-16 07:00:00 |