print1404. Association

printAssociation

Ограничения: время – 2s/4s, память – 64MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

A wireless network connection is a two-way radio communication established after a wire- less client (e.g. a laptop or PDA) associates with a wireless access point (AP). Each client and AP communicate using radio signals whose strength depends on the radio power levels, distance between, interference, and other factors. If the connection is to be secure, the client and AP must both support some common security protocol. In this problem, we are given a list of APs, each having a name and list of supported security protocols. We are also given a list of clients, each having a name, a list of supported security protocols (in preference order), a minimum radio signal strength below which the client refuses to communicate, and a list of APs within radio contact at more than zero signal strength.
Input Format
The first part of the input describes one or more access points (APs), following by an empty input line. The second part of the input describes one or more clients, followed by an empty input line. Each AP consists of a nonempty line containing the AP name, followed by one or more nonempty lines containing the names of security protocols the AP supports, followed by an empty line. Each client consists of a nonempty line containing the client name, followed by one or more nonempty lines containing names of security protocols the client supports, followed by an input line containing a nonnegative integer-the minimum radio signal strength below which the client refuses to communicate, followed by zero or more nonempty lines containing the name of an AP and a positive integer-the signal strength-separated by white space.
Output Format
For each client in the input, determine which (if any) of the APs within radio contact the client will associate with. Clients prefer the AP with which they can communicate at the highest signal strength, but will ignore any AP whose radio signal strength is less than the client's minimum threshold, and will ignore any AP that does not support at least one security protocol the client supports. If a client associates with an AP, then the security protocol used is the client's most preferred protocol among those supported by both. If a client is willing to associate with two or more APs having equally high signal strength, then it associates with the one listed first in the input. If a client associates with an AP, then output the result as shown in the output sample below, else output the message "client xxx is not associated".

Sample Input

ap1
protocol1
protocol3
protocol5

ap2
protocol1
protocol2
protocol3


client1
protocol2
protocol5
5
ap1 4
ap2 6

client2
protocol1
protocol2
protocol3
protocol4
protocol5
0
ap1 8
ap2 8

client3
protocol2
3
ap1 3
ap2 4


Sample Output

client client1 associates with AP ap2 using protocol protocol2 at signal strength 6
client client2 associates with AP ap1 using protocol protocol1 at signal strength 8
client client3 associates with AP ap2 using protocol protocol2 at signal strength 4
Source: California State Polytechnic University Programming Contest, Spring 2010
loading