2 shunfurh shunfurh 于 2017.01.16 18:53 提问

What's In A Name?

Description

The FBI is conducting a surveillance of a known criminal hideout which serves as a communication center for a number of men and women of nefarious intent. Using sophisticated decryption software and good old fashion wiretaps, they are able to decode any e-mail messages leaving the site. However, before any arrest warrants can be served, they must match actual names with the user ID's on the messages. While these criminals are evil, they're not stupid, so they use random strings of letters for
their ID's (no dillingerj ID's found here). The FBI knows that each criminal uses only one ID. The only other information they have which will help them is a log of names of the people who enter and leave the hideout. In many cases, this is enough to link the names to the ID's.
Input

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

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.
Sample Input

7
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
Sample Output

bonnie:fatman
booth:???
clyde:frenchie
knuckles:bigman
moriarty:???
mugsy:mangler
ugati:sinbad

1个回答

caozhy
caozhy   Ds   Rxr 2017.01.22 23:44
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
POJ 1043 What's In A Name? 已被翻译
-
OCP-1Z0-053-200题-70题-647
QUESTION 70 You executed the following commands in a database session: SQL> SELECT object_name, original_name FROM user_recyclebin; OBJECT_NAME ORIGINAL_NAME -------------------------------- -----
Kaggle:What's Cooking?
What's Cooking? Use recipe ingredients to categorize the cuisine Picture yourself strolling through your local, open-air market... What do you see? What do you smell? What will you make fo
locale::facet::_S_create_c_locale name not valid解决方案
在很多的shell脚本中,我们经常会看见某一句命令的前面有一句“LC_ALL=C” SAR_CMD="LC_ALL=C sar -u -b 1 5 | grep -i average " 这到底是什么意思? LC_ALL=C 是为了去除所有本地化的设置,让命令能正确执行。 --------------------------------- 转帖:http://www.linuxsky.org/doc
python input和raw_input的区别
python input和raw_input的区别inputname = input("what's your name?") print "hello"+nameinput函数假定用户输入的是合法的Python表达式,直接输入将会报错!如下: what’s your name?vince Traceback (most recent call last): File “/Users/vi
实验吧CTF题库 what a fuck!这是什么鬼东西? 题解
题目地址:http://www.shiyanbar.com/ctf/56分析:打开网站后发现是一堆莫名其妙的代码。。然后发现是一种叫JSFuck的东西,将网站内容复制粘贴到下面这个网站:http://www.jsfuck.com/然后运行一下,就出来答案了。实际上这是一种jother编码,实际上是一种利用JavaScript语言,利用少量字符构造精简的函数匿名方法,代码会比较冗杂。...
OCP-1Z0-053-V13.02-453题
453.What is the danger associated with stopping a running job by using the STOP_JOB procedure? A. The job will need to be reenabled before it will execute again. B. The job may hold locks on objects
国外论坛注册常见的防止机器人的问题及答案
Question Alan Roberts' special super glue was used to join what?  What was the name of the first home computer to be manufactured?  What was France's online telecom service called?  Which play
What is an Object?(转载)
Objects defined        So what is an object? An object is a component of a program that knows how to perform certain actions and to interact with other pieces of the program. Functions have previous
what's your name?
本汇编程序显示what's your name?并输入你的名字,要不要循环