#P8878. 『STA - R1』好吃的智慧果子
『STA - R1』好吃的智慧果子
Background
In ancient times, years ago, planted a very precious $\colorbox{black}{\textcolor{red}{\textbf{Wis♂dom♂Tree♂}}}$, which was seen by .
After years, the tree bore $\colorbox{black}{\textcolor{blue}{\textbf{Wis♂dom♂Fruit♂}}}$.
After another years, the fruit ripened, and really wanted to eat it.
wanted to eat the fruit very much, but all-knowing had already known that wanted his fruit, so he put each fruit into a password box.
Now, has entrusted you with the important task of stealing the fruit.
Problem Description
Formal statement
Maintain a sequence . In each operation, you are given five non-negative integers . For all , update .
Here is the Fibonacci sequence, defined as:
$$f_n=\begin{cases}n&n\leqslant 1\\f_{n-1}+f_{n-2}&n>1\end{cases}$$Original statement
All-knowing had long known that was very smart, so he would change the password from time to time.
Each password box has a number on it, forming the sequence .
There are operations on the password. In each operation, five integers are given, meaning that for all satisfying , change into ( denotes the -th term of the Fibonacci sequence; it is guaranteed that ).
made a recorder to record 's operations. Now, he gives you the recorder, hoping that after finishes all operations, you can figure out the passwords of all the boxes.
Input Format
The first line contains two integers , representing the number of fruits and the number of operations.
The second line contains integers as the sequence , representing the number on each password box.
The next lines describe 's operations .
Output Format
Output one line containing the passwords of all boxes, separated by spaces.
6 2
1 1 4 5 1 4
2 4 2 100 3
3 5 1 97 5
1 4 52 44 6 4
Hint
Constraints
This problem uses bundled testdata.
| Subtask | Score | Special property | |
|---|---|---|---|
| None | |||
| None |
For of the testdata, , , .
Translated by ChatGPT 5