问题2748--Witness Redaction Plan

2748: Witness Redaction Plan

[命题人 : ]
时间限制 : 3.000 sec  内存限制 : 64 MB

题目描述

The Justice Dept runs a Witness Protection Plan in which witnesses to crimes are given new identities to protect them from retaliation by the people against whom they testify in court. Experience has shown that many of the protected witnesses are their own worst enemies - often giving away their new locations and identities in misguided attempts to contact relatives and friends and to assure them that all is well. The plan is experimenting with a new idea of allowing such communications, in email form only, with the idea that employees of the plan will inspect the communications first and cut out any potentially dangerous sentences, then send the email on from Dept computers so that they cannot be traced back to the witness. Unfortunately, the budget for the pilot project was cut almost as soon as the project commenced. There is insufficient money to actually hire people to read all the email, so an automated solution is sought instead. Write a program that, given a list of sensitive words and a message (in plain text form), scans the message for any sentence containing a sensitive word (ignoring differences in upper/lower case). If a sensitive word is found, every character in that sentence (except for line terminators) should be replaced by ’@’ characters. For the purposes of this program, a word is a string of consecutive alphanumeric characters bounded in the message by the start or end of the message and/or by any non-alphanumeric character. A sentence is a string of consecutive characters bounded by the start or end of the message, by a paragraph boundary (a line containing zero characters), and/or by one of the punctuation characters: ’.’, ’?’, or ’!’

输入

Input to the program consists of one or more input sets. Each input set consists of a word list and a message. The end of the input is signaled by a line containing only the left-justified phrase “EndOfInput”. A word list consists of zero or more words, one per line and left-justified. Words may be up to 40 characters in length.The end of the word list is signalled by a line containing only the left-justified phrase “EndOfList”. The word list is immediately followed by a message. A message consists of zero or more lines of text containing up to 80 characters per line. The end of the message is signaled by a line containing only the left-justified phrase “EndOfMsg”.

输出

For each input set, print the message, exactly as it appears in the input except for replacement of sentences by ’@’ characters as described above. At the end of each message, print a line containing only a string of four ’=’ characters, left-justified.

样例输入 Copy

John
jane
Smith
Jones
Kansas
court
crime
phone
555
EndOfList
Dear Mom,

I just wanted to let you know that I am alive and well. Jane is
well also. I’m glad they were able to relocate us. My
only complaint is that I wish they could have found someplace
more exciting than Kansas for us to live in! If you really need
to contact us, you can do so by telephone. The number is
(757) 555-0478, but don’t tell anyone.

Love,
the new John Smith
EndOfMsg
EndOfInput

样例输出 Copy

Dear Mom,

I just wanted to let you know that I am alive and well.@@@@@@@@
@@@@@@@@@@ I’m glad they were able to relocate us.@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ If you really need
to contact us, you can do so by telephone.@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@@@@@
@@@@@@@@@@@@@@@@@@
====

来源/分类