#P8902. [USACO22DEC] Range Reconstruction S
[USACO22DEC] Range Reconstruction S
Description
Bessie has an array , where and for all we have . She will not tell you the array itself, but she will tell you the range of every subarray of . That is, for every pair of indices , Bessie tells you . Given these values, construct an array that could be Bessie's original array. The values in your array must be in the range .
Input Format
The first line contains .
The next lines: line contains the integers .
It is guaranteed that there exists some array , with values in the range , such that for all , .
Output Format
Output one line containing integers in the range , representing your array. These numbers must satisfy that for all , .
3
0 2 2
0 1
0
1 3 2
3
0 1 1
0 0
0
0 1 1
4
0 1 2 2
0 1 1
0 1
0
1 2 3 2
4
0 1 1 2
0 0 2
0 2
0
1 2 2 0
Hint
Sample 1 Explanation
For example, .
Sample 2 Explanation
This sample satisfies the constraints of subtask 1.
Sample 3 Explanation
This sample satisfies the constraints of subtask 2.
Properties of test points
- Test point satisfies .
- Test points satisfy that for all we have .
- Test points have no additional constraints.
Translated by ChatGPT 5
京公网安备 11011102002149号