#P40004. 2019 ICPC NCNA Regional Contest E - Early Orders
2019 ICPC NCNA Regional Contest E - Early Orders
题目描述
You are given a list of integers and a number k.
It is guaranteed that each i from 1 to k appears in the list at least once.Find the lexicographically smallest subsequence of x that contains
each integer from 1 to k exactly once.
输入格式
The first line will contain two integers n and k, with
.
The following n lines will each contain an integer with
.
输出格式
Write out on one line, separated by spaces, the lexicographically smallest
subsequence of x that has each integer from 1 to k exactly once.
样例
输入样例1
6 3
3
2
1
3
1
3
输出样例1
2 1 3
输入样例2
10 5
5
4
3
2
1
4
1
1
5
5
输出样例2
3 2 1 4 5