﻿ Fuzhou University OnlineJudge ﻿
Problem 1678 Simple Permutation

## Problem Description

There are N integers in an array.
Oaiei wants to know the first P simple permutations.
A permutation is a simple permutation only if the element in the permutation is increased.
So the permutation “1 2 3” is a simple permutation, but the permutation “1 3 2” is not a simple permutation.
Please output the first P different simple permutation out of the N integers.
If the number of simple permutations is less than P, just output the all simple permutations.

## Input

There are multiple test cases. For each test case, the first line contains two integers N(1≤N≤100) and P(1≤P≤10000). In the second line, there are N integers which are separated by a blank space. It is guaranteed that the element in the array will fit within a 32-bit signed integer.

## Output

For each test case, output the first P different simple permutation out of the N integers. For more details, please look at the sample input and output.

## Sample Input

3 6 1 2 3 3 7 1 2 3 3 6 1 1 2

## Sample Output

1 2 3 1 2 1 3 2 3 1 2 3 1 2 1 3 2 3 1 2 3 1 2 1 1 1 2 1 1 2

## Source

FOJ月赛-2008年12月

Submit  Back  Status  Discuss
﻿