| IME++ Starters Try-Outs 2025 |
|---|
| Finished |
It was a bright morning at the Institute of Monkey Entertainment (also known as IME) when your favorite instructor of the Center of Annoyance (CA) selected you (through a totally random and unquestionably fair selection process) as the new Duty Scheduler.
For the next $$$T$$$ days, you're responsible for scheduling the daily duty roster: the schedule that determines which unfortunate student must pull duty and stand watch over some mysterious and highly classified location known as Ala.
There are $$$N$$$ students, numbered from $$$1$$$ to $$$N$$$.
Hey, I'm baixado now and can't pull duty for the next $$$x$$$ days. Take me off the list!
If someone gets baixado on day $$$d$$$ for $$$x$$$ days, they are taken off from the list immediately, and their turn is skipped to the next person still on the list. Then, on day $$$d + x$$$, they return to their original position on the list. Keep in mind someone can still stay baixado after the period of $$$T$$$ days, and everyone can be baixado at the same time, so the list would be empty. It is guaranteed only active people will ask to become baixado. If the list is empty (because too many people were baixado) and if some people return to the list on the same day, it'll restart normally beginning with the student with the lowest identification number.
You must now manage this chaos for the next $$$T$$$ days of scheduling while also handling $$$Q$$$ unpredictable queries from people who think you're a walking calendar. Your goal is to determine, for each day from $$$1$$$ to $$$T$$$, which person is going to pull duty on that day.
Will you rise to become the Legendary Duty Scheduler of CA? Or will you break down like every poor soul before you?
The first line contains three integers $$$N$$$, $$$T$$$, and $$$Q$$$ $$$(1 \leq N, T, Q \leq 2 \cdot 10^5, Q \leq \lfloor T/2 \rfloor \cdot N)$$$ — the number of students and the number of queries. The next $$$Q$$$ lines describe the queries in the following format:
Output $$$T$$$ integers in a single line, indicating the student that is going to pull duty on each day. If there is no student to pull duty on such a day, print -1.
5 5 21 2 22 3 1
1 4 5 1 2
5 15 37 3 15002 2 51 1 20000
2 3 4 5 3 4 5 2 4 5 2 4 5 2 4
10 30 106 4 38 8 34 7 56 1 911 4 52 5 616 1 39 2 311 3 39 9 3
1 2 3 4 6 8 9 10 3 4 5 6 7 8 9 10 2 3 4 5 6 7 8 9 10 1 2 3 4 5
In the first sample, 2 is off from day 1 to day 2 and 3 is off only on day 2. So the list starts with but on the second day the next available is 4 and then 5 on day 3. It cycles back to 1 and then 2 on day 5.
On the second sample case, 3 is off from day 7 to day 1500, meaning he is not returning on any day until day 15. 2 will be off from day 2 to day 6, and 1 will be off on all days until 15. The list cycles without 1 until day 5, in which 2 is out. Then the list goes on until day 8, in which 3 is out too. Here, 2 is already back and the list repeats the cycle [2, 4, 5] until the end of day 15.
| Name |
|---|


