Implement a Bounded Ring Buffer Simulator
Model a fixed-capacity FIFO buffer, including full and empty behavior.
Implement a sequential reference model of a bounded FIFO ring buffer. PUSH x inserts x if there is room; otherwise print FULL. POP prints and removes the oldest element, or prints EMPTY when no element is available. Do not confuse this reference model with a thread-safe SPSC implementation; the latter requires additional concurrency reasoning.
Input format
First line: capacity N and number of commands Q. Next Q lines: PUSH x or POP.
Output format
Print a line for every POP and every rejected PUSH, in command order.
Examples
2 6 PUSH 7 PUSH 8 PUSH 9 POP POP POP
FULL 7 8 EMPTY
Constraints
- 1 ≤ N ≤ 100000
- 1 ≤ Q ≤ 100000
- -10^9 ≤ x ≤ 10^9
Related concepts
This early-access exercise uses standard input/output. More advanced concurrency challenges will use specialized class interfaces, instrumentation, and stress tests once the judging infrastructure is ready.
Loading Monaco C++ editor…
Checking whether the external C++ judge is available.
2 6 PUSH 7 PUSH 8 PUSH 9 POP POP POP
FULL 7 8 EMPTY