luogu#P5103. [JOI 2016 Final] 断层 / Geologic Fault
[JOI 2016 Final] 断层 / Geologic Fault
Problem Description
The translator’s ability is limited; I sincerely ask everyone to provide a better translation.
This problem is translated from JOI 2016 Final T5 “断層”.
A very long time ago, an advanced civilization called IOI flourished. As time passed, the modern archaeologist Dr. JOI decided to excavate the ruins of the IOI civilization.
The IOI civilization developed along a straight river. For convenience, the ruins of the IOI civilization can be regarded as the axis of the Cartesian coordinate plane, and the axis represents altitude. The ground surface of the IOI civilization is flat; that is, the line represents the ground, is above the ground, and is underground. In addition, due to sediment deposition, the ground of the IOI civilization kept rising slowly. At years before the fall of the IOI civilization , the line was the ground surface.
After the IOI civilization fell, the strata beneath it moved times. The -th movement is described by position , direction , and amount . is or . Specifically,
- : The fault is considered to be a line passing through with slope . The strata above the fault move diagonally upward: the coordinate increases by , and the coordinate increases by . That is, every point above the line moves to .
- : The fault is considered to be a line passing through with slope . The strata above the fault move diagonally upward: the coordinate decreases by , and the coordinate increases by . That is, every point above the line moves to .
After each crustal movement, all strata with disappear due to weathering.
You are asked: for each , determine which year before the fall of the IOI civilization the stratum between point and point comes from.
On the axis, every fault passes through an integer point, and there is no fault between two adjacent integer points on the axis. This should be clear, right……
Input Format
The first line contains two integers , separated by spaces.
In the next lines, the -th line contains three integers , separated by spaces.
The meanings of all input values are given in the statement.
Output Format
Output lines in total.
The -th line contains one integer, indicating which year before the fall of the IOI civilization the stratum between point and point comes from.
10 2
12 1 3
2 2 2
3
3
5
5
5
5
5
5
2
2
10 6
14 1 1
17 1 1
-6 2 1
3 2 1
4 1 1
0 2 1
5
5
4
5
5
5
5
5
4
4
15 10
28 1 7
-24 2 1
1 1 1
8 1 1
6 2 1
20 1 3
12 2 2
-10 1 3
7 2 1
5 1 2
15
14
14
14
14
12
12
12
12
12
12
12
15
15
12
Hint
Sample Explanation 1

Constraints and Notes
For all testdata, , , or , .
| Subtask # | Other Constraints | Score | |
|---|---|---|---|
| 1 | , | 18 | |
| 2 | None. | 16 | |
| 3 | 66 |
Translated by ChatGPT 5