#P8098. [USACO22JAN] Tests for Haybales G
[USACO22JAN] Tests for Haybales G
Problem Description
Farmer John’s cows decided to hold a programming contest for the cows on Farmer Nhoj’s farm. To make the problems as interesting as possible, they spent a lot of time constructing challenging test cases. In particular, for a problem called “Haybales”, the cows need your help to design challenging test cases. This is about solving the following somewhat strange problem:
There is a sorted integer array (), and an integer . You do not know this array or , but you do know, for each index , the maximum index such that . It is guaranteed that and .
Given this information, Farmer John’s cows need to construct any array and integer that are consistent with it. The construction must satisfy for all , and .
It can be proven that this is always possible. Please help Farmer John’s cows solve this problem.
Input Format
The first line contains . The second line contains .
Output Format
Output , and then on the next line output . Any valid output is accepted.
6
2 2 4 5 6 6
6
1
6
17
22
27
32
Hint
[Sample Explanation]
The sample output is the array and . The condition is satisfied because and , so is the largest element not exceeding . Similarly:
- is satisfied because and ;
- is satisfied because and ;
- is satisfied because and ;
- is satisfied because and is the last element of the array;
- is satisfied because and is the last element of the array.
For the sample input, this is not the only correct output. For example, you could also output the array and .
[Constraints]
- For of the test cases, .
- For the remaining test cases, there are no additional constraints.
[Notes]
This problem uses a self-written Special Judge. If you have questions about this or want to hack, please private message the author or make a post.
Translated by ChatGPT 5