#P5317. Scoring Events Simulation Game
Scoring Events Simulation Game
Scoring Events Simulation Game
This problem simulates a game played on the first and fourth quadrants of a Cartesian coordinate system. In the first quadrant, there will be \(n\) objects. Each object is either a point or a vertical line segment parallel to the \(y\)-axis. When an object appears, the point on it closest to the \(x\)-axis is its lowest point and the point farthest from the \(x\)-axis is its highest point. (For a point object, the two are identical.)
The \(i\)th object appears at time \(t_i\) with its lowest point at \((x_i, l_i)\) and highest point at \((x_i, r_i)\). It moves downward (i.e. in the negative \(y\) direction) at a constant speed \(v_i\). Meanwhile, the player may perform two kinds of operations on integer positions on the positive \(x\)-axis:
- A mark operation, which can be performed at any integer point (even if it has been marked before; marks do not conflict).
- A cancel mark operation, which cancels a previous mark.
The operations occur in pairs. For the \(i\)th pair, the marking operation occurs at time \(a_i\) at position \(p_i\), and the cancel mark operation occurs at time \(b_i\) (with the same position \(p_i\)).
The game works as follows. Initially every object is in a normal state.
At any moment (which is an integer time and during a special settlement phase), the following occurs in order:
- Movement Miss events: Before any operations at time \(t\), all objects already in the game (and not newly appeared at \(t\)) move: their \(y\)-coordinates decrease by their speed \(v_i\) (i.e. both \(l_i\) and \(r_i\) are reduced by \(v_i\)). Then, for any object in the normal state whose lowest point enters the fourth quadrant (i.e. it becomes strictly negative since points on the axes do not belong to any quadrant), a miss event occurs and the object disappears immediately.
- Appearance: All objects with appearance time equal to \(t\) appear.
- Operations: All operations scheduled at time \(t\) occur simultaneously. It is guaranteed that at any given time, a mark operation is not cancelled in the same moment. For the marking operations: if there is a mark operation at some position \(p\) such that the Euclidean distance between \((p,0)\) and the object’s lowest point \((x_i,l_i)\) is at most \(d_0\) and the object is in the normal state, a scoring event is triggered. If multiple mark operations satisfy the condition, the one with the smallest distance \(d = \sqrt{(p-x_i)^2+l_i^2}\) is chosen; if still tied, the one with the smallest \(p\) is chosen. Once an object triggers a mark scoring event, its scoring parameter is \(d\). Then, if the object is a point (i.e. \(l_i=r_i\)), it vanishes immediately; otherwise, it becomes marked and remembers the mark position.
- Cancellation operations: Similarly, for an object in the marked state, if at some moment a cancel mark operation occurs at a position \(p\) and the Euclidean distance between \((p, 0)\) and the object’s highest point \((x_i,r_i)\) is at most \(d_0\), a scoring event is triggered with parameter \(d = \sqrt{(p-x_i)^2+r_i^2}\) and the object then vanishes. If a cancel mark operation is performed on an object (i.e. on its corresponding mark) but does not trigger a scoring event, then a miss event occurs for that object and it vanishes immediately.
- Scoring: Each scoring event with parameter \(d\) awards a base score of \((d_0^2-d^2)s_1\). In addition, if before the current scoring event there was a consecutive streak of \(k-1\) scoring events (and either the \(k\)th previous event was not a scoring event or it does not exist), then an additional bonus of \(ks_2\) is awarded. (The streak is broken by any miss event.)
The game ends immediately when either all objects have appeared and disappeared or when the number of miss events becomes strictly greater than \(w\). Operations that occur after the game ends are ignored.
You are given the details of the objects and the operation pairs. Compute the final total score.
Input Format:
n m d0 s1 s2 w // Next n lines: t x l r v // Next m lines: a b p
Output Format:
A single integer representing the final score.
inputFormat
The first line contains six integers: n, m, (d_0), (s_1), (s_2), and w.\n\nThe next n lines each contain five integers: t, x, l, r, v, representing an object that appears at time t with its lowest point at ((x, l)) and highest point at ((x, r)) and moving downward with speed v.\n\nThe next m lines each contain three integers: a, b, p, representing a pair of operations. For the i-th pair, a mark operation is performed at time a at position p, and a cancel mark operation is performed at time b at the same position p.
outputFormat
Output the final score as a single integer.
sample
0 0 5 2 10 1
0