CodeForces 637B Chat Order

来源:互联网 发布:横截面数据举例 编辑:程序博客网 时间:2024/06/07 21:07

思路:水题..其实就是把输入的字符串倒着输出就行了,加个map判重就可以了


#include <cstdio>#include <queue>#include <cstring>#include <iostream>#include <cstdlib>#include <algorithm>#include <vector>#include <map>#include <string>#include <set>#include <ctime>#include <cmath>#include <cctype>using namespace std;#define maxn 200005#define LL long longint cas=1,T;map<string,int> visit;string s[maxn];int main(){int n;while (scanf("%d",&n)!=EOF){for (int i = 0;i<n;i++){cin >> s[i];        //visit[s[i]]=1;}for (int i = n-1;i>=0;i--){if (!visit[s[i]])cout << s[i] << endl;visit[s[i]]=1;}}//freopen("in","r",stdin);//scanf("%d",&T);//printf("time=%.3lf",(double)clock()/CLOCKS_PER_SEC);return 0;}

Description

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.

Input

The first line contains integer n (1 ≤ n ≤ 200 000) — 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.

Output

Print all the recipients to who Polycarp talked to in the order of chats with them, from top to bottom.

Sample Input

Input
4alexivanromanivan
Output
ivanromanalex
Input
8alinamariaekaterinadaryadaryaekaterinamariaalina
Output
alinamariaekaterinadarya


0 0
原创粉丝点击