Time Limit: Java: 10000 ms / Others: 10000 ms
Memory Limit: Java: 32768 KB / Others: 32768 KB
Input consists of one problem instance. The first line contains a single positive
integer n indicating the number of criminals using the hideout. The maximum
value for n will be 20. The next line contains the n user ID's, separated by
single spaces. Next will be the log entries in chronological order. Each entry
in the log has the form type arg, where type is either E, L or M; E indicates
that criminal arg has entered the hideout; L indicates criminal arg has left
the hideout; M indicates a message was intercepted from user ID arg. A line
containing only the letter Q indicates the end of the log. Note that not all
user ID's may be present in the log but each criminal name will be guaranteed
to be in the log at least once. At the start of the log, the hideout is presumed
to be empty. All names and user ID's consist of only lowercase letters and have
length at most 20. Note: the line containing only the user ID's may contain
more than 80 characters.
Output consists of n lines, each containing a list of criminal names and their
corresponding user ID's, if known. The list should be sorted in alphabetical
order by the criminal names. Each line has the form name:userid, where name
is the criminal's name and userid is either their user ID or the string ???
if their user ID could not be determined from the surveillance log.
This problem contains multiple test cases!
The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.
The output format consists of N output blocks. There is a blank line between
17 bigman mangler sinbad fatman bigcheese frenchie capodicapo E mugsy E knuckles M bigman M mangler L mugsy E clyde E bonnie M bigman M fatman M frenchie L clyde M fatman E ugati M sinbad E moriarty E booth Q
bonnie:fatman booth:??? clyde:frenchie knuckles:bigman moriarty:??? mugsy:mangler ugati:sinbad