P1438 Boring Sequence
Background
The bored YYB always comes up with things that normal people would not. One day, the bored YYB came up with a boring problem: a boring sequence.
Description
Maintain a sequence $a_i$ supporting two operations:
- `1 l r K D`: You are given an arithmetic progression of length $r - l + 1$ with first term $K$ and common difference $D$, and you add it correspondingly to each number in the range $[l, r]$. Specifically: let $a_l=a_l+K,a_{l+1}=a_{l+1}+K+D\ldots a_r=a_r+K+(r-l) \times D$.
- `2 p`: Query the value of the $p$-th element $a_p$.
Input Format
The first line contains two integers $n, m$ denoting the length of the sequence and the number of operations.
The second line contains $n$ integers, where the $i$-th number is $a_i$.
Each of the next $m$ lines starts with an integer $opt$.
If $opt = 1$, then four more integers $l\ r\ K\ D$ follow.
If $opt = 2$, then one more integer $p$ follows.
Output Format
For each query, output one integer per line representing the answer.
Explanation/Hint
Constraints
For $100\%$ of the testdata, $0\le n,m \le 10^5,-200\le a_i,K,D\le 200, 1 \leq l \leq r \leq n, 1 \leq p \leq n$.
Translated by ChatGPT 5