QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 512 MB Puntuación total: 100

#18788. Dãy số và truy vấn 30

Estadísticas

Cho dãy số $A_1, A_2, \ldots, A_N$ có độ dài $N$. Hãy viết chương trình thực hiện các truy vấn sau:

  • 1 L R X: Với mọi $L \le i \le R$, gán $A_i = A_i + X$.
  • 2 L R S E: Thay đổi đoạn $[L, R]$ của $A$ thành các số trong đoạn $[S, E]$. Nghĩa là, gọi $B$ là dãy kết quả sau truy vấn này, thì $B_L = A_S, B_{L+1} = A_{S+1}, \ldots, B_R = A_E$, và với mọi $i$ không nằm trong $L \le i \le R$, $B_i = A_i$.
  • 3 L R: In ra $A_L + A_{L+1} + \ldots + A_R$.

Dữ liệu vào

Dòng đầu tiên chứa kích thước $N$ của dãy số. ($1 \le N \le 200\,000$)

Dòng thứ hai chứa $A_1, A_2, \ldots, A_N$. ($-10^6 \le A_i \le 10^6$)

Dòng thứ ba chứa số lượng truy vấn $M$. ($1 \le M \le 200\,000$)

$M$ dòng tiếp theo, mỗi dòng chứa một truy vấn. ($1 \le L \le R \le N$, $1 \le S \le E \le N$, $E-S = R-L$, $-10^6 \le X \le 10^6$) Truy vấn loại 3 xuất hiện ít nhất một lần.

Dữ liệu ra

In ra kết quả của các truy vấn loại 3, mỗi kết quả trên một dòng.

Ví dụ

Dữ liệu vào 1

5
1 2 3 4 5
5
3 1 5
1 1 3 1
3 1 3
2 1 3 2 4
3 1 5

Dữ liệu ra 1

15
9
20

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.