GPU Reservations
Your team shares a training cluster of C identical GPUs. The planning horizon is n hours,
numbered 1 to n. Engineers don't grab GPUs directly; they send requests to a reservation
service, which processes them one at a time in the order received. Requests are numbered 1 to
q in that order.
There are two kinds of requests:
book l r k: reservekGPUs for every hour fromltor, inclusive. The service accepts the booking if, in every hour fromltor, the GPUs already reserved by active bookings pluskis at mostC. An accepted booking becomes active. Otherwise the booking is rejected and changes nothing. A booking is never partially granted.cancel j: requestjis abookrequest that came earlier. If it was accepted and is still active, it stops being active and its GPUs are released for all of its hours. If it was rejected, or has already been cancelled, nothing happens.
For each book request, report whether the service accepts it.
Input
The first line contains three integers n, C and q (1 ≤ n ≤ 2·10^5, 1 ≤ C ≤ 10^9,
1 ≤ q ≤ 2·10^5): the number of hours, the number of GPUs and the number of requests.
Each of the next q lines describes one request, in order. The i-th of them is either
book l r k (1 ≤ l ≤ r ≤ n, 1 ≤ k ≤ 10^9) or cancel j (1 ≤ j < i), where request j is
guaranteed to be a book request.
Output
For each book request, in input order, print a line containing ACCEPT if it is accepted or
REJECT if it is rejected. Print nothing for cancel requests.
Notes
In the first example, request 2 is rejected because hour 3 already has 2 of the 3 GPUs reserved. After request 1 is cancelled, request 5 is still rejected, because hours 4 and 5 are fully taken by request 3, but request 6 fits exactly.
In the second example, cancel 2 does nothing because request 2 was rejected, and the second
cancel 1 does nothing because request 1 is no longer active.