QOJ.ac

QOJ

حد الوقت: 50 s حد الذاكرة: 1024 MB مجموع النقاط: 100

#14735. Reading report on "A theory of consciousness from a theoretical computer science perspective: Insights from the Conscious Turing Machine" (Updating...)

الإحصائيات

Given a sequence $a_1, \dots, a_n$ of length $n$, you need to perform $m$ operations of three types:

Operation 1: Given $l, r, x$, first create a new array $b$ such that $b_i = a_i$, then update $a_x, \dots, a_{x+r-l}$ to be equal to $b_l, \dots, b_r$ respectively.

Operation 2: Given $l, r$, update $a_l, \dots, a_r$ by replacing each element with its value divided by $2$ (rounded down).

Operation 3: Given $l, r$, calculate the sum of $a_l, \dots, a_r$.

Input

The first line contains an integer $n$.

The next line contains $n$ integers representing the sequence $a_1, \dots, a_n$.

The next line contains an integer $m$.

The next $m$ lines each describe an operation:

1 l r x represents operation 1;

2 l r represents operation 2;

3 l r represents operation 3.

Output

For each operation 3, output one line containing an integer representing the answer.

Examples

Input 1

10
1 81 93 81 16 97 63 26 66 13
10
1 1 5 3
3 5 6
3 9 9
3 1 3
3 1 7
2 1 3
3 3 9
1 5 6 6
3 1 4
3 3 9

Output 1

174
66
83
354
363
121
440

Input 2

10
61 53 17 97 81 17 1 91 38 93
10
2 3 6
2 1 8
3 1 5
3 1 1
3 1 7
3 3 5
3 1 4
2 2 10
2 1 5
3 5 5

Output 2

104
30
108
48
84
5

Subtasks

For $100\%$ of the data, $1 \le n \le 3 \cdot 10^6$ and $1 \le m \le 3 \cdot 10^6$.

The initial values of the sequence satisfy $1 \le a_i \le 10^9$.

For each operation, $1 \le l \le r \le n$.

For each operation 1, $1 \le x \le x+r-l+1 \le n$.

All values above are integers.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.