303289: CF637B. Chat Order
Memory Limit:256 MB
Time Limit:3 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Chat Order
题意翻译
## 题目描述 有一个队列,初始时为空。现在依次插入 $n$ 个单词,如果这个单词已经在队列中,那就把这个单词从原来位置移到队首,否则直接把这个单词放到队首。问你最后这个队列长啥样。 ## 输入输出格式 ### 输入格式: 第一行,一个整数 $n$ ( $1 \le n \le 200000 $),表示单词的数量。接下来 $n$ 行,每行一个单词,每个单词都由小写字母构成,非空且长度均不超过 $10$ 。 ### 输出格式: 若干行,每行一个单词,依次表示从队首到队尾的每个单词。题目描述
Polycarp is a big lover of killing time in social networks. A page with a chatlist in his favourite network is made so that when a message is sent to some friend, his friend's chat rises to the very top of the page. The relative order of the other chats doesn't change. If there was no chat with this friend before, then a new chat is simply inserted to the top of the list. Assuming that the chat list is initially empty, given the sequence of Polycaprus' messages make a list of chats after all of his messages are processed. Assume that no friend wrote any message to Polycarpus.输入输出格式
输入格式
The first line contains integer $ n $ ( $ 1<=n<=200000 $ ) — the number of Polycarpus' messages. Next $ n $ lines enlist the message recipients in the order in which the messages were sent. The name of each participant is a non-empty sequence of lowercase English letters of length at most $ 10 $ .
输出格式
Print all the recipients to who Polycarp talked to in the order of chats with them, from top to bottom.
输入输出样例
输入样例 #1
4
alex
ivan
roman
ivan
输出样例 #1
ivan
roman
alex
输入样例 #2
8
alina
maria
ekaterina
darya
darya
ekaterina
maria
alina
输出样例 #2
alina
maria
ekaterina
darya