QOJ.ac

QOJ

実行時間制限: 4 s メモリ制限: 512 MB 満点: 100

#18785. Dãy số và Truy vấn 27

統計

Cho dãy $A_1, A_2, \ldots, A_N$ có độ dài $N$, và hai dãy $B$ và $C$ có độ dài $N$, ban đầu thỏa mãn $B_i = A_i$ và $C_i = A_i$. Hãy viết chương trình xử lý 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 Y: Với mọi $L \le i \le R$, gán $A_i = \max(A_i, Y)$.
  • 3 L R Y: Với mọi $L \le i \le R$, gán $A_i = \min(A_i, Y)$.
  • 4 L R: In ra $\min(A_L, A_{L+1}, \ldots, A_R)$.
  • 5 L R: In ra $\min(B_L, B_{L+1}, \ldots, B_R)$.
  • 6 L R: In ra $\max(C_L, C_{L+1}, \ldots, C_R)$.

Sau mỗi truy vấn, với mọi $1 \le i \le N$, cập nhật $B_i = \min(B_i, A_i)$ và $C_i = \max(C_i, A_i)$.

Dữ liệu vào

Dòng đầu chứa số nguyên $N$, độ dài của dãy. ($1 \le N \le 500{,}000$)

Dòng thứ hai chứa $N$ số nguyên $A_1, A_2, \ldots, A_N$. ($-10^9 \le A_i \le 10^9$)

Dòng thứ ba chứa số nguyên $M$, số lượng truy vấn. ($1 \le M \le 500{,}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$, $-2{,}000 \le X \le 2{,}000$, $-10^9 \le Y \le 10^9$) Các truy vấn loại $4$, $5$ và $6$ mỗi loại xuất hiện ít nhất một lần.

Dữ liệu ra

Với mỗi truy vấn loại $4$, $5$ và $6$, in ra kết quả, mỗi kết quả trên một dòng riêng biệt.

Ví dụ

Đầu vào 1

3
1 2 3
6
5 3 3
1 2 3 -2
3 1 3 0
5 3 3
2 2 3 4
5 1 3

Đầu ra 1

3
0
0

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.