#B4319. Auditorium Activity Scheduling

    ID: 11975 Type: Default 1000ms 256MiB

Auditorium Activity Scheduling

Auditorium Activity Scheduling

The school auditorium can host at most one activity at a time. Every activity reserves a single day in one of three time slots: morning (M), afternoon (A), or evening (E). Activities are booked one by one in chronological order of submission. Each booking has three pieces of information:

  • Activity Type \( type_i \): a capital letter where \( O \) represents an official school event, \( C \) represents a club event, and \( P \) represents a personal event.
  • Activity Date \( date_i \): given in the format YYYYMMDD (for example, 20250411 stands for April 11, 2025).
  • Activity Time Slot \( time_i \): a capital letter, with M for morning, A for afternoon, and E for evening.

Immediately after each booking is added to the schedule, a conflict resolution process is triggered. A conflict occurs if two or more events are scheduled at the same date and time slot. To resolve any conflict, the following rules are applied repeatedly until no conflicts remain:

  1. If the conflicting events have different types, the event with the lower priority is postponed by exactly one day (the time slot remains unchanged). The priority order is defined as follows: \( O \) (official) \( > \) \( C \) (club) \( > \) \( P \) (personal).
  2. If the conflicting events have the same type, the event that was booked later (i.e. with a higher submission index) is postponed by one day.
  3. Postponing an event to the next day may create new conflicts, and the process is repeated until the schedule is conflict-free.

Your task is to simulate the booking and conflict resolution process and output the final scheduled date for each event in the order the bookings were submitted.

inputFormat

The first line contains an integer \( n \) (the number of booking requests). Each of the following \( n \) lines contains a booking request with three values separated by spaces:

  • A character \( type_i \) (one of O, C, P),
  • A string \( date_i \) in YYYYMMDD format,
  • A character \( time_i \) (one of M, A, E).

outputFormat

Output \( n \) lines, where the \( i^{th} \) line is the final scheduled date (in YYYYMMDD format) for the \( i^{th} \) booking request (in the order they were submitted).

sample

3
O 20250411 M
C 20250411 M
P 20250411 M
20250411

20250412 20250413

</p>