#K3366. Video Streaming Service Queue Simulator
Video Streaming Service Queue Simulator
Video Streaming Service Queue Simulator
This problem simulates a queue management system for a video streaming service. You are required to maintain a queue that supports the following operations:
- ADD x: Add video x to the end of the queue if it is not already present.
- DELETE x: Remove video x from the queue if it exists.
- POSITION x: Print the 1-indexed position of video x in the queue; if x is not present, print
NOT FOUND
. - VIDEO y: Print the video at position y (1-indexed) in the queue; if y is out of bounds, print
NOT FOUND
. - PRINT: Print the current queue as space separated integers; if the queue is empty, print
EMPTY QUEUE
.
Your implementation should process a series of operations and produce outputs for the operations that generate a result (POSITION
, VIDEO
and PRINT
).
Note: In this problem, commands will be provided from standard input, and you should output the results to standard output.
inputFormat
The first line of input contains an integer n representing the number of operations. Each of the following n lines contains one operation command. The commands will be one of the following:
ADD x
DELETE x
POSITION x
VIDEO y
PRINT
Here, x and y are integers. The operations should be processed in the given order.
outputFormat
For each operation that requires an output (POSITION
, VIDEO
and PRINT
), print the result on a new line.
- If the operation is
POSITION x
, print the 1-indexed position of x in the queue, orNOT FOUND
if the video is not in the queue. - If the operation is
VIDEO y
, print the video at the y-th position in the queue, orNOT FOUND
if y is out of bounds. - If the operation is
PRINT
, print the entire queue as space separated integers, orEMPTY QUEUE
if the queue is empty.
6
ADD 101
ADD 102
POSITION 101
VIDEO 2
DELETE 101
PRINT
1
102
102
</p>