Pearls and Converter
In this problem, we are dealing with a mystical race known as the pearls, who are on a mission to find a set of pearls to power their spaceship. The pearls are represented by a peaceful race, and they need to efficiently manage the pearls they have, as they are limited in both time and resources.
The task is to determine the maximum number of sets of pearls that can be formed from the pearls produced by a device called a pearl converter. This device produces pearls at a rate of one per second, and each pearl is of a different color. The pearls are represented by integers, and the task is to ensure that each set contains a specific number of pearls, each of a different color, and that the time between the appearance of these pearls does not exceed a certain time limit.
The goal is to determine the maximum number of sets that can be formed from the pearls produced by the pearl converter.
Input
The input consists of two lines. The first line contains three integers:
- 'n' - the number of pearls produced by the pearl converter. - 'm' - the maximum time interval, in seconds, between the appearance of the pearls in a set. - 'k' - the number of different colors of pearls.
The second line contains 'n' integers, each representing the color of a pearl in the order in which they were produced.
Output
The output should consist of two parts:
1. The first line should contain a single integer 'x', which is the maximum number of sets that can be formed from the pearls. 2. The following 'x' lines should each contain 'k' integers, representing the indices of the pearls in the set.
Each pearl can only belong to one set, and the time interval between the appearance of the pearls in a set must not exceed 'm' seconds.
Scoring
The problem is divided into five subtasks, each with specific conditions:
1. (15 points) - 'n = m', 'n ≤ 1000'. 2. (10 points) - 'k = 2', 'n ≤ 1000'. 3. (15 points) - 'k ≤ 10', 'n ≤ 1000'. 4. (30 points) - 'n ≤ 1000'. 5. (30 points) - Full constraints.
The solution must pass all tests for the subtask to receive the points, including all required subtasks. If there are multiple valid solutions, any one of them can be provided.