TCCC '24 Jan P1 - Hamlet Translator

View as PDF

Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 128M

Author:
Problem type

In the famous play Hamlet by William Shakespeare, the theme of revenge is built up mainly through the main character, Hamlet. The effect that this theme has on the direction of the play is evident through Hamlet’s actions. As Hamlet progresses down the path of revenge, his actions become more illogical, resulting in him harming himself and others.

This theme initially reveals itself when Hamlet converses with the ghost of his dead father, the former king of Denmark. The ghost informs Hamlet that his death was not accidental and that the current king and uncle to Hamlet, Claudius, is responsible. Hamlet tells his friend and scholar Horatio that he does not trust the ghost yet and is planning to investigate Cladius, but from his later actions, we see him lean towards what the ghost says.

As Horatio is a good friend, he wants to understand the true meaning behind Hamlet’s madness and what he says. After careful observation, Horatio has determined an alternate meaning to certain words Hamlet says. Unfortunately, Horatio is unable to apply these translations in real-time. Given a list of these words and their true meaning, help Horatio translate what Hamlet says.

Input Specifications

The first line contains integer N (1 \le N \le 10^3), the number of translations to consider.

The next N lines contain a word with the number of letters ranging from (1 - 25), followed by its true meaning separated by a space.

The following line consists of integer W, (1 \le w \le 10^4).

The next line contains W words, the number of words that Hamlet speaks, W (1 \le w \le 10^4).

The final line will be something Hamlet says, w words separated by a space to be translated.

There will be no punctuation and letters may be capitalized. All words to be translated and their true meanings will be unique from each other.

Output Specifications

Output the quote translated with the true meaning.

Sample Input 1

1
ghost father
7
I trust and will follow my ghost

Sample Output 1

I trust and will follow my father

Explanation

the word ghost is replaced by the word father to get the sample output.


Comments

There are no comments at the moment.