1974: [USACO 2022 December Contest Silver] Problem 3. Range Reconstruction
文件提交:无需freopen
内存限制:256 MB
时间限制:2.000 S
评测方式:普通裁判
命题人:
提交:13
解决:0
题目描述
Bessie has an array , where and for all . She won't tell you itself, but she will tell you the range of each subarray of . That is, for each pair of indices , Bessie tells you . Given these values of , please construct an array that could have been Bessie's original array. The values in your array should be in the range .
输入
The first line contains .
Another lines follow. The th of these lines contains the integers .
It is guaranteed that there is some array with values in the range such that for all , .
输出
Output one line containing integers in the range representing your array. They must satisfy for all .
样例输入
3
0 2 2
0 1
0
样例输出
1 3 2
提示
For example, .
SAMPLE INPUT:
3
0 1 1
0 0
0
SAMPLE OUTPUT:
0 1 1
This example satisfies the constraints for subtask 1.
SAMPLE INPUT:
4
0 1 2 2
0 1 1
0 1
0
SAMPLE OUTPUT:
1 2 3 2
This example satisfies the constraints for subtask 2.
SAMPLE INPUT:
4
0 1 1 2
0 0 2
0 2
0
SAMPLE OUTPUT:
1 2 2 0
SCORING:
- Test 5 satisfies .
- Tests 6-8 satisfy for all .
- Tests 9-14 satisfy no additional constraints.