#C1026. List Manager Operations

    ID: 39445 Type: Default 1000ms 256MiB

List Manager Operations

List Manager Operations

You are given an initially empty list L. Your task is to process a series of queries to modify and query the list. There are three types of operations:

  1. Insertion: Given a query in the format 0 p x, insert the element x into the list at position p. The list is zero-indexed. After insertion, the new element appears at index p and subsequent elements move one position to the right.
  2. Rotation: Given a query in the format 1 d k, rotate the list by k positions. If d = 0, perform a left rotation; if d = 1, perform a right rotation. Mathematically, if n is the current length of the list, the effective rotation is performed by k mod n. In latex, this is represented as \(k \% n\).
  3. Range Minimum Query: Given a query in the format 2 l r, output the minimum value in the subarray from index l to index r (inclusive).

You need to process the queries sequentially. For every query of type 2, print the corresponding result on a new line.

inputFormat

The input is read from stdin and is formatted as follows:

  • The first line contains an integer Q representing the number of queries.
  • The next Q lines each contain a query. Each query is one of the following forms:
    • 0 p x — insert element x at index p.
    • 1 d k — rotate the list. If d is 0, rotate left by k positions; if d is 1, rotate right by k positions.
    • 2 l r — output the minimum element in the subarray from index l to r (inclusive).

outputFormat

For each query of type 2, output the computed minimum value on a separate line to stdout.

## sample
10
0 0 5
0 1 3
2 0 1
0 1 4
1 0 1
2 0 2
1 1 2
0 0 2
2 0 3
1 0 1
3

3 2

</p>