176. Circular Queue
Now the queue has a fixed capacity c, and the array holding it is reused
as values come and go.
The point is that a queue which has had many values pass through it should not run out of
room while most of its array sits unused. Once tail reaches the end of the array it
continues from the beginning — it WRAPS AROUND — and the space freed by earlier removals
becomes available again.
If an add happens while the queue holds c values, print Full and ignore that add.
Constraints - `1 ≤ c ≤ 200000` - `1 ≤ q ≤ 200000` - `-1000000 ≤ x ≤ 1000000`
Input
The first line contains two integers c and q — the capacity and the number of operations.
Each of the next q lines is one operation:
- 1 x — add x to the back
- 2 — remove the front value and print it
- 3 — print the front value without removing it
Output
Print one line for each 2 and 3 operation — the value, or Empty.
Print Full on its own line for each 1 that is rejected because the queue is at capacity.
A successful 1 prints nothing.