luogu#P7922. [Kubic] Pyramid
[Kubic] Pyramid
Background
It is easy to see that the setter of Problem F is not lxl.

Problem Description
You are given a sequence with initial length .
Let the current length of be . There are two kinds of operations:
-
Operation A first constructs a sequence of length such that . Then replace with .
-
Operation B first constructs a sequence of length such that . Then replace with .
You are also given a sequence of length , meaning there are groups of operations. In the -th group, perform times operation A first, and then perform times operation B. It is guaranteed that .
Finally, you are given queries. Each query provides parameters . You need to compute the value of after the first operations.
Note: in the queries, means the first operations, not the first groups of operations. That is, a query may happen in the middle of some group of operations.
Input Format
The first line contains three integers .
The second line contains integers, where the -th integer denotes .
The third line contains integers, where the -th integer denotes .
The next lines each contain three integers , representing one query.
Output Format
Output lines. Each line contains one integer. The integer on the -th line is the answer to the -th query.
5 2 3
6 2 4 1 3
1 1
1 1 4
2 2 3
4 1 1
6
3
2
Hint
For of the data, $1\le n,m,q\le 1.5\times 10^5,1\le x<n,1\le l\le r\le n-x,1\le p_i\le 10^9,2\sum a_i=n-1$.
| Score | Time Limit | Special Properties | ||||
|---|---|---|---|---|---|---|
| None | ||||||
| No special limits | No special limits | No special limits | AB | |||
| B | ||||||
| C | ||||||
| None | ||||||
| No special limits | ||||||
Special Property A: .
Special Property B: .
Special Property C: .
Sample Explanation
The given operation process is as follows:
6 2 4 1 3
2 2 1 1
2 2 1
2 1
2
Writing special properties separately is only to make the table look nicer...
Thanks to for contributing to this problem!
Translated by ChatGPT 5