#abc299g. G - Minimum Permutation
G - Minimum Permutation
Score : points
问题描述
我们有一个长度为 的整数序列 ,其中的整数都在 到 之间。在此条件下,从 到 的每个整数至少在序列 中出现一次。
在 的所有长度为 的子序列中,每个整数 各恰好出现一次,请找出字典序最小的那个子序列。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have a sequence of length consisting of integers between and . Here, every integer from to appears at least once in .
Among the length- subsequences of where each of appears once, find the lexicographically smallest one.
Constraints
- Every integer between and , inclusive, appears at least once in .
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Let be the sought subsequence, and print it in the following format:
Sample Input 1
4 3
2 3 1 3
Sample Output 1
2 1 3
The length- subsequences of where each of appears once are and . The lexicographically smaller among them is .
Sample Input 2
4 4
2 3 1 4
Sample Output 2
2 3 1 4
Sample Input 3
20 10
6 3 8 5 8 10 9 3 6 1 8 3 3 7 4 7 2 7 8 5
Sample Output 3
3 5 8 10 9 6 1 4 2 7
update @ 2024/3/10 12:25:08