#C1562. Inventory Management in Text-Based Games
Inventory Management in Text-Based Games
Inventory Management in Text-Based Games
You are tasked with managing the inventory of a character in a text-based game.
The inventory has a maximum capacity \(m\), and you will receive a series of commands to modify it. The commands are:
- ADD item_name: Add an item to the inventory. If the inventory is already full, output "Inventory full".
- REMOVE item_name: Remove an item from the inventory. If the item is not found, output "Item not found".
- LIST: List all items in the inventory, separated by commas. If the inventory is empty, output "Inventory empty".
For each dataset, the first line contains two integers \(m\) (the maximum capacity) and \(q\) (the number of commands). The following \(q\) lines each contain a command.
Process the commands in the given order and output the results (if any) produced by each command. For commands that do not require output (successful ADD or REMOVE), simply continue to the next command.
inputFormat
The input begins with an integer \(T\) (the number of datasets/test cases). For each test case:
- A line containing two integers: \(m\) (maximum capacity of the inventory) and \(q\) (number of commands).
- Then \(q\) lines follow, each containing one command: either
ADD item_name
,REMOVE item_name
, orLIST
.
outputFormat
For every command that produces an output, print the result on a new line. The outputs for each test case should follow consecutively in the order the commands are executed.
## sample1
5 7
ADD sword
ADD shield
ADD potion
LIST
REMOVE shield
LIST
REMOVE axe
sword,shield,potion
sword,potion
Item not found
</p>