atcoder#ABC251H. [ABC251Ex] Fill Triangle
[ABC251Ex] Fill Triangle
Score : points
Problem Statement
Blocks are stacked in a triangle. The -th column from the top has blocks.
You are given a sequence which is a result of the run-length compression of a sequence consisting of non-negative integers less than or equal to .
- For example, when , you are given .
You will write a number on each block so that the following conditions are satisfied, where denotes the number to write on the -th block from the left in the -th column from the top:
- For all integers such that , it holds that .
- For all pairs of integers such that , it holds that .
Enumerate the numbers written on the blocks in the -th column from the top.
What is run-length compression?
The run-length compression is a conversion from a given sequence to a sequence of pairs of integers obtained by the following procedure.
- Split off at the positions where two different elements are adjacent to each other.
- For each subsequence that has been split off, replace with a integer pair of "the number which consists of" and "the length of ".
- Construct a sequence consisting of the integer pairs after the replacement without changing the order.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer in the following format. It is guaranteed that the answer is unique under the Constraint of the problem.
6 3 4
2 3
5 2
1 1
1 4 3 2
We have . The number written on the blocks are as follows.
3
5 5
5 0 5
1 4 3 2
4 4 0 3 6
2 2 2 5 5 1
1 1 1
6 1
6
111111111 9 9
0 1
1 10
2 100
3 1000
4 10000
5 100000
6 1000000
0 10000000
1 100000000
1 0 4 2 5 5 5 6 3