#P9588. 「MXOI Round 2」队列
「MXOI Round 2」队列
Problem Description
Little C has a queue, and he wants to perform operations on it. There are four types of operations, with parameters as follows:
: This is the first type of operation, meaning to insert into the back of the queue in order.
: This is the second type of operation, meaning to pop the first elements from the front of the queue.
: This is the third type of operation, meaning to query the -th element in the queue.
: This is the fourth type of operation, meaning to query the maximum value among all elements in the queue.
You need to help him maintain this queue, and for each operation of the third and fourth type, output the answer to the query.
Input Format
The first line contains two integers , where denotes the test point ID. indicates that this test point is the sample.
The next lines each contain integers, representing an operation. The format is given in the Description.
Output Format
For each operation of the third and fourth type, output one integer per line, which is the answer to the query.
0 9
1 5
1 3
2 2
1 4
3 6
3 8
2 4
4
3 3
3
2
4
1
Hint
Sample Explanation #1
After the 4th operation, the elements in the queue in order are .
After the 7th operation, the elements in the queue in order are .
Sample #2
See queue/queue2.in and queue/queue2.ans in the additional files.
This sample satisfies the constraints of test point .
Sample #3
See queue/queue3.in and queue/queue3.ans in the additional files.
This sample satisfies the constraints of test point .
Sample #4
See queue/queue4.in and queue/queue4.ans in the additional files.
This sample satisfies the constraints of test point .
Sample #5
See queue/queue5.in and queue/queue5.ans in the additional files.
This sample satisfies the constraints of test point .
Sample #6
See queue/queue6.in and queue/queue6.ans in the additional files.
This sample satisfies the constraints of test point .
Constraints
Let denote the sum of within a single test point.
For of the testdata, , , . It is guaranteed that before performing an operation of the second type, the number of elements in the queue is at least ; before performing an operation of the third type, the number of elements in the queue is at least ; before performing an operation of the fourth type, the number of elements in the queue is greater than .
| Test Point ID | Special Property | |||
|---|---|---|---|---|
| C | ||||
| None | ||||
| AB | ||||
| B | ||||
| AC | ||||
| C | ||||
| None | ||||
Special Property A: There is no operation of the second type.
Special Property B: There is no operation of the third type.
Special Property C: There is no operation of the fourth type.
Translated by ChatGPT 5