#P40037. 2016 UCF Practice Local Contest B - g2g c u l8r

2016 UCF Practice Local Contest B - g2g c u l8r

本题judge有问题,勿做\color{red}本题judge有问题,勿做

题目描述

According to the national statistics, a teenager sends/receives 100+ text messages a day. Dr. Orooji’s teenage children are no exception but the problem is Dr. O (an old-fashioned, face-to- face communicator) has difficulty reading text messages full of abbreviations (short-hands) sent to him by his children. Dr. O needs your help reading these text messages.

The Problem:

Given the list of abbreviations and a paragraph, you are to expand the text (paragraph) so that Dr. O can read it easily.

输入格式

The first input linecontains an integer,n (1 ≤ n ≤ 20),indicating the number of abbreviations. Theseabbreviations are on the followingninputlines, one per line. Each input linestarts in column 1 and containsan abbreviation (1-5 characters, consisting of only lowercaseletters and/or digits). The abbreviation is followed by exactly one space, and this isfollowed by the expanded version ofthe abbreviation (1-50 characters, consisting of only lowercase letters and spaces; assume the expandedversion does not start or end with aspace and contains no multiple consecutive spaces between words).Assume that all abbreviations are distinct, i.e., no duplicates.

The list of abbreviations isfollowed by a positive integer,p,indicating the number of input lines containingthe paragraph to be expanded. Theparagraph is on the followingpinputlines. Assume these input linesdo not exceed column 50, donot start or end with a space, and each line contains at least one word. The paragraph will contain only lowercaseletters, digits, and spaces. Assume that there will not be multipleconsecutive spaces in theinput paragraph.

A word is defined as aconsecutive sequence of letters/digits. Assume that a word will be entirely on oneinput line, i.e., a word isnot broken over two or more lines.

输出格式

Each line of the inputparagraph must be on one line of output. Theinput line must be printed in theoutput exactly the same (spacing). Theonly exception is that each abbreviation must be replaced by its expanded version, i.e., when an abbreviation isfound in the input, its expanded version must beoutput.

Note that an abbreviationmust match a word completely and not just part of a word. For example,if u is an abbreviation for “you”, then u must appear as a word by itself in the paragraph

in order to be replaced,i.e., if the abbreviation is part of a word in the paragraph (e.g.,the paragraph containsthe word buy or ugly or you),the u in these words should not be replaced.

样例

样例输入

8
g2g got to go
g good
c see
l8 late
l8r later
d i am done
u you
r are
6
hi
how r u
you tell me
you are l8
d
c u l8r

样例输出

hi
how are you
you tell me
you are late
i am done
see you later