|
||||||||||
Boring data structure problemTime Limit: 12000/6000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1874 Accepted Submission(s): 601 Problem Description "Why don't you write some background story for this boring data structure problem?" "Because it's too boring..." There's a queue(not the original queue one may refer to as a data structure, here a double-ended queue, to be more precise) that is initially empty. Then, there are infinite elements numbered $1,2,\dots$, entering the queue in the order of their numbers(i.e., the first element to enter the queue is numbered $1$, the second, $2$ et cetera). If an element leaves the queue, it will not enter the queue anymore. Now there are $q$ operations, each in one of the following forms:
Input The first line of each test case contains one number $q(1\leq q \leq 10^7)$, denoting the number of operations. Then $q$ lines follow, each in one of the following forms:
It is guaranteed that the number of operations of the third and the fourth type is both less than $1.5\cdot 10^6$. Output For each operation of the fourth kind, output a number in a line, denoting the answer to the query. Sample Input
Sample Output
Source | ||||||||||
|