You are a software engineer hired by a dental clinic to implement an appointment management system that would allow clinic staffs to create and manage customer appointments. More specifically, your task is to design a C/C++ program that maintains the current appointment records and updates the appointment status according to the commands received.
Your program should support the following four commands:
add N T Schedule an appointment for customer N at time T. If time T is already occupied by another customer, the command is considered invalid. Output -1 and do not modify the current appointment records.change N T1 T2 Change customer N's existing appointment from time T1 to time T2. If customer N does not have an appointment at T1, or if time T2 is already occupied by another customer, the command is considered invalid. Output -1 and do not modify the current appointment records.delete N T Cancel customer N's appointment at time T. If customer N does not have an appointment at time T, the command is considered invalid. Output -1 and do not modify the current appointment records.search T Query the customer who has an appointment after T. Find and output the name of the appointment with the smallest timestamp greater than T. If no such appointment exists, output -1.Your program MAY use C/C++ standard library headers.
The first line contains an integer M, representing the number of commands that follow. The next M lines each contain one command. Where:
N is the name of a customer and consists of English letters with a length between 1 and 50 characters (only lowercase).T is an appointment time represented as a Unix epoch timestamp in seconds, where 0 <= T <= 253402300799.M satisfies 1 <= M <= 5*10^5.The format of every input command is guaranteed to be valid.
For each command:
add, change, and delete produce no output.search outputs the name of the customer who has the appointment at the specified time.-1.Each output should be terminated by a newline character ('\n'). An invalid command must not modify the current appointment records.