首页 > ACM题库 > HDU-杭电 > hdu 2787 Careful Declaration待解决[解题报告]C++
2014
02-14

hdu 2787 Careful Declaration待解决[解题报告]C++

Careful Declaration

问题描述 :

"Do not panic!" That is not only the inscription on a famous book cover, but it is also a message that all banks need to deliver to their clients during every and each crisis, whatever negligible. If the clients started to panic, it would mean the end for any bank.

To calm down their clients, the banks and governments may issue various declarations stating that there is really nothing to worry about. It is very important for such declarations to be consistent, otherwise the people may not believe them.

Imagine that we have two declarations, one suggested by a bank and the other coming from the government. They finally decided to merge those two declarations into a single one and issue it together. (People may think there is some problem if there are too many declarations.) Both the bank and the government insist that the common declaration must contain the whole text of their original declarations.

Your task is to create the joint declaration that will be issued at a press conference tonight. The main condition is that the resulting text must contain all words from the two original proposals, in the same order. Also, we have to keep the declaration as short as possible.

输入:

The input contains several test cases, each consisting of two lines of text giving two original declarations. Both lines contain at least one and at most two thousand words separated by a space. Each of the words is formed by lowercase letters of the English alphabet (a-z). Each word will contain at least one such letter and no more than 10 letters. There is a single dot (".") after the last word of each declaration, the dot is also preceded by one space.

There is one additional line with a single dot after the last test case in the input.

输出:

The input contains several test cases, each consisting of two lines of text giving two original declarations. Both lines contain at least one and at most two thousand words separated by a space. Each of the words is formed by lowercase letters of the English alphabet (a-z). Each word will contain at least one such letter and no more than 10 letters. There is a single dot (".") after the last word of each declaration, the dot is also preceded by one space.

There is one additional line with a single dot after the last test case in the input.

样例输入:

all our banks are sound and safe .
all deposits in our bank are safe do not worry .
everything fine firmly under control .
deposits in bank abc are fine like nothing is .
.

样例输出:

all deposits in our bank banks are sound and safe do not worry .
deposits everything in bank abc are fine firmly like nothing is under control .