#K56452. Concert Time Slot Management
Concert Time Slot Management
Concert Time Slot Management
You are given n singers with their respective initial performance starting times. Additionally, there are q queries to manage their time slots dynamically. The queries are of three types:
- Type 1: Update the starting time of a given singer. That is, change the starting time to a new value.
- Type 2: Mark a singer's slot as unavailable. After this operation, the singer cannot perform at the previously assigned time.
- Type 3: Check the availability of a singer's time slot. If the singer's slot is still available and the starting time matches the queried time, output the time; otherwise, output
unavailable
.
The operations follow these rules. Let \( n \) denote the number of singers and \( q \) denote the number of queries. Initially, each singer has a starting time provided in the input. Then, for each query:
- For a query of type 1: update the starting time of a specified singer.
- For type 2: mark the slot as unavailable (i.e. it is no longer valid for performance).
- For type 3: if the singer's slot is available and the current starting time equals the provided query time, output that starting time. Otherwise, output
unavailable
.
All numerical values and indices satisfy \( 1 \leq n, q \leq 10^5 \). The singer indices are 1-indexed.
Note: All formulas, such as \( n \) and \( q \), are written in \( \LaTeX \) format.
inputFormat
Input is given via stdin with the following structure:
- The first line contains two integers \( n \) and \( q \), where \( n \) is the number of singers and \( q \) is the number of queries.
- The second line contains \( n \) space-separated integers representing the initial starting times for each singer.
- Each of the next \( q \) lines contains three integers:
query_type
,singer_index
(1-indexed), andparameter
.
outputFormat
Output the result for each query of type 3 on a new line. For such queries, if the singer's slot is available and the queried time matches the current starting time, output the starting time; otherwise, output unavailable
.
4 5
10 20 30 40
1 2 25
2 3 0
3 1 10
3 2 25
3 3 30
10
25
unavailable
</p>