#abc251h. Ex - Fill Triangle
Ex - Fill Triangle
Score : points
问题描述
三角形堆叠了一排排的积木。从顶部数第 列有 块积木。
你得到一个序列 ,它是由非负整数序列 (其中所有元素不大于6)进行运行长度压缩的结果。
- 例如,当 时,你得到的 。
你需要在每块积木上写一个数字,确保满足以下条件,其中 表示从顶部数第 列中从左数第 块积木上要写的数字:
- 对于所有满足 的整数 ,都有 。
- 对于所有满足 的整数对 ,都有 。
请列举出从顶部数第 列积木上所写的数字。
什么是运行长度压缩?运行长度压缩是一种将给定序列 转换为整数对序列的过程,按照以下步骤进行:
- 在相邻两个不同元素的位置将 断开。
- 对于每个已断开的子序列 ,用“组成 的数字”和“ 的长度”构成的整数对替换 。
- 不改变顺序地构建经过替换后所得的所有整数对组成的序列。
以上为通义千问 qwen-max 翻译,仅供参考。
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.
Sample Input 1
6 3 4
2 3
5 2
1 1
Sample Output 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
Sample Input 2
1 1 1
6 1
Sample Output 2
6
Sample Input 3
111111111 9 9
0 1
1 10
2 100
3 1000
4 10000
5 100000
6 1000000
0 10000000
1 100000000
Sample Output 3
1 0 4 2 5 5 5 6 3
update @ 2024/3/10 10:44:50