atcoder#ABC299G. [ABC299G] Minimum Permutation
[ABC299G] Minimum Permutation
Score : points
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:
4 3
2 3 1 3
2 1 3
The length- subsequences of where each of appears once are and . The lexicographically smaller among them is .
4 4
2 3 1 4
2 3 1 4
20 10
6 3 8 5 8 10 9 3 6 1 8 3 3 7 4 7 2 7 8 5
3 5 8 10 9 6 1 4 2 7