#C12939. Conference Schedule Manager

    ID: 42421 Type: Default 1000ms 256MiB

Conference Schedule Manager

Conference Schedule Manager

You are required to implement a conference schedule manager that handles multiple tracks and sessions. Each track is defined by a starting time \(T_s\) and an ending time \(T_e\) (i.e., the available time window is \(T_e - T_s\)). Sessions added to a track are scheduled sequentially starting at \(T_s\) in the order they are added. If a session does not fit in the remaining time, output an error message in the following format:

Session session_name cannot be scheduled due to time constraints.

You must support the following commands:

  • ADD_TRACK track_name start_time end_time: Adds a new track with the given time window.
  • ADD_SESSION track_name session_name duration: Adds a new session to the specified track.
  • CREATE_SCHEDULE: Computes the schedule for all tracks by assigning each session the earliest possible starting time.
  • UPDATE_SCHEDULE track_name session_name new_start_time: Updates the start time of an already scheduled session (the duration remains the same).
  • GET_SCHEDULE: Outputs the current schedule.

Make sure that sessions in each track are scheduled consecutively and that the total duration does not exceed the track's available time. All time values are integers.

inputFormat

The input begins with an integer \(N\), which indicates the number of commands. Each of the next \(N\) lines contains one command. The commands can be one of the following:

  • ADD_TRACK track_name start_time end_time
  • ADD_SESSION track_name session_name duration
  • CREATE_SCHEDULE
  • UPDATE_SCHEDULE track_name session_name new_start_time
  • GET_SCHEDULE

For example:

5
ADD_TRACK Track1 9 17
ADD_SESSION Track1 Session1 2
ADD_SESSION Track1 Session2 3
CREATE_SCHEDULE
GET_SCHEDULE

outputFormat

When the GET_SCHEDULE command is encountered, print the schedule for each track. For each track, output the track name on one line, followed by one line per session in that track. Each session line should contain the session name, the start time, and the end time, separated by spaces.

If a scheduling error occurs (i.e. during the CREATE_SCHEDULE command, if a session does not fit in the track's time window), print the error message exactly as follows and terminate the program:

Session session_name cannot be scheduled due to time constraints.
## sample
5
ADD_TRACK Track1 9 17
ADD_SESSION Track1 Session1 2
ADD_SESSION Track1 Session2 3
CREATE_SCHEDULE
GET_SCHEDULE
Track1

Session1 9 11 Session2 11 14

</p>