#abc251h. Ex - Fill Triangle

Ex - Fill Triangle

Score : 600600 points

问题描述

三角形堆叠了一排排的积木。从顶部数第 ii 列有 ii 块积木。

你得到一个序列 P=((a1,c1),(a2,c2),...,(aM,cM))P = ((a_1, c_1), (a_2, c_2), ..., (a_M, c_M)),它是由非负整数序列 A=(A1,A2,...,AN)A = (A_1, A_2, ..., A_N)(其中所有元素不大于6)进行运行长度压缩的结果。

  • 例如,当 A=(2,2,2,5,5,1)A = (2, 2, 2, 5, 5, 1) 时,你得到的 P=((2,3),(5,2),(1,1))P = ((2, 3), (5, 2), (1, 1))

你需要在每块积木上写一个数字,确保满足以下条件,其中 Bi,jB_{i,j} 表示从顶部数第 ii 列中从左数第 jj 块积木上要写的数字:

  • 对于所有满足 1iN1 \leq i \leq N 的整数 ii,都有 BN,i=AiB_{N,i} = A_{i}
  • 对于所有满足 1jiN11 \leq j \leq i \leq N-1 的整数对 (i,j)(i, j),都有 Bi,j=(Bi+1,j+Bi+1,j+1)mod7B_{i,j}= (B_{i+1,j}+B_{i+1,j+1})\bmod 7

请列举出从顶部数第 KK 列积木上所写的数字。

什么是运行长度压缩?运行长度压缩是一种将给定序列 AA 转换为整数对序列的过程,按照以下步骤进行:

  1. 在相邻两个不同元素的位置将 AA 断开。
  2. 对于每个已断开的子序列 BB,用“组成 BB 的数字”和“BB 的长度”构成的整数对替换 BB
  3. 不改变顺序地构建经过替换后所得的所有整数对组成的序列。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Blocks are stacked in a triangle. The ii-th column from the top has ii blocks.

You are given a sequence P=((a1,c1),(a2,c2),...,(aM,cM))P = ((a_1, c_1), (a_2, c_2), ..., (a_M, c_M)) which is a result of the run-length compression of a sequence A=(A1,A2,...,AN)A = (A_1, A_2, ..., A_N) consisting of non-negative integers less than or equal to 66.

  • For example, when A=(2,2,2,5,5,1)A = (2, 2, 2, 5, 5, 1), you are given P=((2,3),(5,2),(1,1))P = ((2, 3), (5, 2), (1, 1)).

You will write a number on each block so that the following conditions are satisfied, where Bi,jB_{i,j} denotes the number to write on the jj-th block from the left in the ii-th column from the top:

  • For all integers ii such that 1iN1 \leq i \leq N, it holds that BN,i=AiB_{N,i} = A_{i}.
  • For all pairs of integers (i,j)(i, j) such that 1jiN11 \leq j \leq i \leq N-1, it holds that Bi,j=(Bi+1,j+Bi+1,j+1)mod7B_{i,j}= (B_{i+1,j}+B_{i+1,j+1})\bmod 7.

Enumerate the numbers written on the blocks in the KK-th column from the top.

What is run-length compression? The run-length compression is a conversion from a given sequence AA to a sequence of pairs of integers obtained by the following procedure.

  1. Split AA off at the positions where two different elements are adjacent to each other.
  2. For each subsequence BB that has been split off, replace BB with a integer pair of "the number which BB consists of" and "the length of BB".
  3. Construct a sequence consisting of the integer pairs after the replacement without changing the order.

Constraints

  • 1N1091 \leq N \leq 10^9
  • 1Mmin(N,200)1 \leq M \leq \min(N, 200)
  • 1Kmin(N,5×105)1 \leq K \leq \min(N,5 \times 10^5)
  • 0ai60 \leq a_i \leq 6
  • 1ciN1 \leq c_i \leq N
  • i=1Mci=N\sum_{i=1}^M c_i = N
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM KK

a1a_1 c1c_1

a2a_2 c2c_2

\vdots

aMa_M cMc_M

Output

Print the answer in the following format. It is guaranteed that the answer is unique under the Constraint of the problem.

BK,1B_{K,1} BK,2B_{K,2} \dots BK,KB_{K,K}

Sample Input 1

6 3 4
2 3
5 2
1 1

Sample Output 1

1 4 3 2

We have A=(2,2,2,5,5,1)A = (2,2,2,5,5,1). 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