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 xx axis of the Cartesian coordinate plane, and the yy axis represents altitude. The ground surface of the IOI civilization is flat; that is, the line y=0y=0 represents the ground, y>0y>0 is above the ground, and y<0y<0 is underground. In addition, due to sediment deposition, the ground of the IOI civilization kept rising slowly. At aa years before the fall of the IOI civilization (a0)(a\geqslant 0), the line y=ay=-a was the ground surface.

After the IOI civilization fell, the strata beneath it moved QQ times. The ii-th movement (1iQ)(1\leqslant i\leqslant Q) is described by position XiX_i, direction DiD_i, and amount LiL_i. DiD_i is 11 or 22. Specifically,

  • Di=1D_i=1: The fault is considered to be a line passing through (Xi,0)(X_i, 0) with slope 11. The strata above the fault move diagonally upward: the xx coordinate increases by LiL_i, and the yy coordinate increases by LiL_i. That is, every point (x,y)(x,y) above the line moves to (x+Li,y+Li)(x+L_i, y+L_i).
  • Di=2D_i=2: The fault is considered to be a line passing through (Xi,0)(X_i, 0) with slope 1-1. The strata above the fault move diagonally upward: the xx coordinate decreases by LiL_i, and the yy coordinate increases by LiL_i. That is, every point (x,y)(x,y) above the line moves to (xLi,y+Li)(x-L_i, y+L_i).

After each crustal movement, all strata with y>0y>0 disappear due to weathering.

You are asked: for each ii (1iN)(1\leqslant i\leqslant N), determine which year before the fall of the IOI civilization the stratum between point (i1,0)(i-1,0) and point (i,0)(i,0) comes from.

On the yy axis, every fault passes through an integer point, and there is no fault between two adjacent integer points on the yy axis. This should be clear, right……

Input Format

The first line contains two integers N,QN, Q, separated by spaces.
In the next QQ lines, the ii-th line (1iQ)(1\leqslant i\leqslant Q) contains three integers Xi,Di,LiX_i, D_i, L_i, separated by spaces.
The meanings of all input values are given in the statement.

Output Format

Output NN lines in total.
The ii-th line (1iN)(1\leqslant i\leqslant N) contains one integer, indicating which year before the fall of the IOI civilization the stratum between point (i1,0)(i-1,0) and point (i,0)(i,0) 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, 1N,Q2×1051\leqslant N, Q\leqslant 2\times 10^5, 109Xi109-10^9\leqslant X_i\leqslant 10^9, Di=1D_i=1 or 22, 1Li1091\leqslant L_i\leqslant 10^9 (1iQ)(1\leqslant i\leqslant Q).

Subtask # N,QN,Q Other Constraints Score
1 N,Q100N,Q\leqslant 100 100Xi100-100\leqslant X_i\leqslant 100, Li=1L_i=1 (1iQ)(1\leqslant i\leqslant Q) 18
2 N,Q3000N,Q\leqslant 3000 None. 16
3 N,Q2×105N,Q\leqslant 2\times10^5 66

Translated by ChatGPT 5