#P10639. Sequence Interval Operations

    ID: 12665 Type: Default 1000ms 256MiB

Sequence Interval Operations

Sequence Interval Operations

You are given a sequence of integers of length \(n\). The sequence supports the following 6 operations:

  • Operation 1: For an interval \([l, r]\), add an integer \(x\) to each element in the interval.
  • Operation 2: For an interval \([l, r]\), if an element is less than \(x\), change it to \(x\).
  • Operation 3: For an interval \([l, r]\), if an element is greater than \(x\), change it to \(x\).
  • Operation 4: Query the sum of the interval \([l, r]\).
  • Operation 5: Query the maximum value in the interval \([l, r]\).
  • Operation 6: Query the minimum value in the interval \([l, r]\).

Each operation is given in the following format:

  • For operations 1, 2, and 3, the input line is: op l r x.
  • For operations 4, 5, and 6, the input line is: op l r.
  • Note: The intervals are 1-indexed.

    inputFormat

    The first line of input contains two integers \(n\) and \(m\), representing the length of the sequence and the number of operations, respectively.

    The second line contains \(n\) integers representing the initial values of the sequence.

    Each of the next \(m\) lines describes an operation. For operations 1, 2, 3, the line contains four integers: op l r x (where op is 1, 2, or 3). For operations 4, 5, 6, the line contains three integers: op l r.

    outputFormat

    For each operation that is a query (i.e. operations 4, 5, and 6), output the answer on a separate line.

    sample

    5 6
    1 2 3 4 5
    1 1 3 2
    4 1 5
    2 2 5 5
    5 1 5
    3 1 3 4
    6 1 5
    21
    

    5 3

    </p>