#P4146. 序列终结者

    ID: 4861 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 显示难度提高+/省选− 上传者: 标签>模拟线段树平衡树

序列终结者

Background

There are many problems online where, given a sequence, you need to support several operations: A, B, C, D. Then you see another problem: again a sequence with operations to support: D, C, B, A. Especially someone here, when making a mock exam, even made one like this. Honestly, there is not much technical content in that...

So I will also make one. My goal is to let everyone have a “library” to rely on when solving such problems in the future, nothing else.

Let’s call this problem Sequence Terminator.

Problem Description

Given a sequence of length NN, each element is an integer (trivial). You need to support the following three operations:

  1. Add VV to every number in the interval [L,R][L,R].
  2. Reverse the interval [L,R][L,R], for example, 1 2 3 4 becomes 4 3 2 1.
  3. Query the maximum value in the interval [L,R][L,R].

Initially, all elements are 00.

Input Format

The first line contains two integers NMN,M. MM is the number of operations.

The next MM lines each contain up to four integers, in order: KLRVK,L,R,V. KK indicates the operation type. If it is not the 11st operation, then only two numbers follow KK.

Output Format

For each operation of type 33, output the correct answer.

4 4
1 1 3 2
1 2 4 -1
2 1 3
3 2 4
2

Hint

1N500001\le N \le 500001M1000001\le M \le 100000V1000|V| \leq 1000

Translated by ChatGPT 5