#P10701. [SNCPC2024] 致命公司
[SNCPC2024] 致命公司
Problem Description
Shirost has recently been addicted to a game called Lethal Company.
In the game, players act as contractors of the “Company” and collect scrap from abandoned industrial planets. During exploration, Shirost will encounter a monster called a “Springhead”. A Springhead moves quickly when nobody is watching it, but stays still when it is being watched. Once it gets close, the Springhead will kill Shirost immediately.
Now Shirost is standing at the intersection of infinitely long corridors. He knows that there are Springheads: the -th Springhead will appear at time , in corridor , at a position meters away from him.
For each time , the following three events happen in order:
-
At the beginning of this time, every Springhead with appears in corridor , at a position meters away from Shirost.
-
Shirost chooses to stare at any one corridor.
-
All Springheads in that corridor cannot move, while Springheads that have already appeared in other corridors move meters toward him. If any Springhead reaches Shirost’s position, then he will die at time .
Shirost wants to know the latest time he can stay alive. In other words, if Shirost dies at the latest at time , you need to output . If he will never die, output .
Input Format
The first line contains three integers ($1 \leq n \leq 5 \times 10^5, 1 \leq m \leq 5 \times 10^5, 1 \leq k \leq 10^{18}$), separated by spaces, representing the number of infinitely long corridors, the number of Springheads, and the distance a Springhead moves each time unit.
The next lines each contain three integers ($1 \leq t_i \leq 10^{18}, 1 \leq x_i \leq n, 1 \leq y_i \leq 10^{18}$), separated by spaces, describing the time when a Springhead appears, the corridor index where it appears, and how far it is from Shirost.
Output Format
Output one integer in a single line, indicating the latest time Shirost can stay alive. If he will never die, output .
2 3 2
1 1 6
2 2 7
3 1 8
6
114514 6 1919810
1 1 1
1 1 9
1 4 1
1 5 9
1 1 8
1 4 10
0
Hint
Shirost can act as follows: | Time | Corridor stared at | Springhead distance | Springhead distance | Springhead distance | | :----------: | :----------: | :----------: | :----------: | :----------: | | 1 | 1 | 6 | | | | 2 | 1 | 6 | 5 | | | 3 | 2 | 4 | 5 | 6 | | 4 | 1 | 4 | 3 | 6 | | 5 | 2 | 2 | 3 | 4 | | 6 | 1 | 2 | 1 | 4 |
At time , no matter which corridor he stares at, Shirost will be killed by a Springhead during this time. Therefore, the answer is .
Translated by ChatGPT 5