CF1234B1 Social Network (easy version)

题目描述

你知道了将来N次给你发送的消息,而聊天软件一次性只能显示与K(1≤K≤200)个人的聊天记录。 当收到一条消息时,如果与这个人的聊天记录显示在聊天软件中,就什么都不做(注意,不需要把当前聊天记录置顶);否则,如果当前已经显示了K个聊天记录,则删除最后一个聊天记录;添加与这个人的聊天记录在列表顶端,同时其他聊天记录下移一个位置。 询问在这N条消息发送之后,你的聊天软件最终会显示与哪几个人的聊天记录。

输入格式

第一行两个正整数N,K(1≤N,K≤200),表示N条发来的消息和一次性显示的聊天记录个数。 接下来一行N个正整数id[i] (1≤id[i]≤200),为第i条消息的发送者。

输出格式

第一行,输出最后屏幕上显示的聊天记录个数X。 接下来一行X个正整数,按顺序输出最后屏幕上显示的聊天记录的对象。

说明/提示

In the first example the list of conversations will change in the following way (in order from the first to last message): - $ [] $ ; - $ [1] $ ; - $ [2, 1] $ ; - $ [3, 2] $ ; - $ [3, 2] $ ; - $ [1, 3] $ ; - $ [1, 3] $ ; - $ [2, 1] $ . In the second example the list of conversations will change in the following way: - $ [] $ ; - $ [2] $ ; - $ [3, 2] $ ; - $ [3, 2] $ ; - $ [1, 3, 2] $ ; - and then the list will not change till the end.