Problem 397
Queue Operations
Easy · 10 pts · Queue, Design, Simulation
Problem
Simulate a queue (first in, first out) that starts empty and supports four operations. 'enqueue x' adds x to the back. 'dequeue' removes the front element and prints it, or prints EMPTY if the queue is empty. 'front' prints the front element without removing it, or EMPTY if the queue is empty. 'size' prints the number of elements. Every operation should take O(1) time.
Input
First line: Q, the number of operations. Next Q lines: one operation each.
Output
Print the output of every dequeue, front and size operation on its own line.
Constraints
1 <= Q <= 100000; -1000000000 <= x <= 1000000000; at least one operation produces output
Example input
5 enqueue 5 enqueue 7 front dequeue size
Example output
5 5 1
Explanation
After enqueue 5 and enqueue 7, front prints 5, dequeue removes and prints 5, and size prints 1 because only 7 is left.