this image is AI generated
To congratulate you on your recent achievements in developing a successful delivery service system (refer to question 14311 & 14598 for a fun backstory), you were promoted to be the manager of a new project, welcome to ‘Spider-Man’s Queue Service: Project Stacks & Queue’!
In the restaurants where our food delivery Spider-Men will pick up their order, people have to line up in a queue to order/get their food. However, due to the restaurant’s popularity there are so many people at the restaurant. When one queue is overloaded, the restaurant would open another queue to speed up the lines of impatient customers. But since opening a new queue and having a staff to attend to it consumes so much resource, the restaurant would try to close the additional queues as soon as the line becomes empty. Your task is to implement a system to keep track of the lines, this data is vital for Spider-Man’s Delivery Service data analytics team!
Enter <ct> <num> <p>
During this command, you will be given a character <ct>, and integers <num> and <p>.
Where <ct> represents the customer type, and <num> represents the total number of customers who entered the store. Lastly, <p> represents the patience of each of the customers. When the command is called, you must queue the customers into the first queue available (starting from the bottom of the stack). If the queue reaches its current capacity, move to the next queue, if all current queues in the stack are full you must push a new queue with the same capacity as the remaining customers. Enqueue all the remaining customers into the newly created queue. Each customer added will be assigned a unique ID, starting with 0.
Each customer type will be one of the following: Regular, Grumpy, and Spider-man type! Each has its own unique behavior (explained below).
Resize <q_id> <new_cap>
Given <q_id> an integer that represents the queue ID to resize, and <new_cap> an integer that represents the new capacity. You will resize the specified queue to a new capacity.
*<q_id> is a unique ID given to the queue when pushed into the stack.
Process
Process the customers that are waiting next in line. During this stage, the tasks will be handled in the following order starting from the first queue in the stack (bottom of the stack) and the first element of the queue. Complete each stage for all queues in the stack before moving to the next stage (pay attention to this):
Spider-Man customer type only appear from testcase 4 onwards. Grumpy customer only appear from testcase 6 onwards.
You're recommended to use OOP to solve this problem.
More hints may be given during TA lab on Mondays if deemed necessary.
The first line will contain an integer <qs> which specifies the capacity of the initial queue in the stack.
The following lines will be one of the commands:
|
Parameter name |
Details |
Size |
|
qs |
The initial capacity of the queue |
1 ≤ qs ≤ 1,000 |
|
ct |
Customer type |
‘R’, ‘S’, or ‘G’ |
|
num |
Number of customers |
1 ≤ num ≤ 2,000 |
|
p |
Customer initial patience |
2 ≤ p ≤ 5,000 |
|
q_id |
Queue ID to be resized |
Current IDs in the stack |
|
new_cap |
Queue’s new capacity |
1 ≤ new_cap ≤ 1,000 |
Output according to the specifications:
It should then be followed by a summary of the remaining elements in each queue:
Repeat the same format for all the remaining customers in the queue, separated by: “, “ Enter a newline after every output.
*<q_id> represents the queue ID the event happens.
*<new_q_id> represents the target queue ID.
*<customer_id> represents the customer’s ID.