#C13707. Ticket Booking System
Ticket Booking System
Ticket Booking System
You are required to implement a ticket booking simulation for various events. Each event can have multiple time slots with a given capacity and a current number of booked seats. For a booking attempt, you must check whether the event exists, whether the specified time slot exists, and if there is available capacity for that time slot. If the booking is successful, update the count and print a success message; otherwise, print an appropriate failure message.
The expected messages are as follows:
- Successful booking: \(\texttt{Ticket successfully booked for \{event_id\} at \{time_slot\} for \{user_id\}}\)
- Event not found: \(\texttt{Event ID \{event_id\} not found.}\)
- Time slot not found: \(\texttt{Time slot \{time_slot\} for event \{event_id\} not found.}\)
- Full capacity: \(\texttt{Ticket booking failed - \{event_id\} at \{time_slot\} is fully booked}\)
You must read the input from standard input (stdin) and write your output to standard output (stdout).
inputFormat
The first line of input contains an integer \(E\) that represents the number of events. For each event, the following lines are provided:
- A line with the event ID (a string) followed by an integer \(S\), the number of time slots available for that event.
- Then, \(S\) lines follow. Each line contains a time slot (string), an integer \(capacity\), and an integer \(booked\) representing the number of seats already booked.
After all event data, a line containing an integer \(T\) is given, which represents the number of booking attempts. Then, \(T\) lines follow, each containing three strings: \(event_id\), \(time_slot\), and \(user_id\), representing one booking attempt.
outputFormat
For each booking attempt, output a single line with one of the following messages:
- Success: "Ticket successfully booked for {event_id} at {time_slot} for {user_id}"
- Event not found: "Event ID {event_id} not found."
- Time slot not found: "Time slot {time_slot} for event {event_id} not found."
- Full capacity: "Ticket booking failed - {event_id} at {time_slot} is fully booked"
The output for each booking attempt should be on its own line.
## sample1
event1 1
10:00AM 100 50
1
event1 10:00AM user123
Ticket successfully booked for event1 at 10:00AM for user123
</p>