题目描述
Problem Description
Little K enjoys playing rhythm games, especially one called "dimou". The judgment mechanism of dimou is as follows: dimou is a single-screen (unlike something that starts with "dy") falling rhythm game. Specifically, there is a judgment line at the bottom of the screen. A song has several hit points (i.e., keys, which can be seen as a line segment parallel to the judgment line with only left-right width). Each key falls from the top at a constant speed and the player needs to click it as accurately as possible when it coincides with the judgment line.
Of course, the player might click before the key touches the judgment line or after it has fallen below the judgment line. In these cases, the game's judgment system needs to be considered to tally the player's performance on a song. Dimou has three judgments: perfect, good, and miss. There are six scenarios:
Scenario 1: The player clicks at least 1 second before a key reaches the judgment line (denoted as $\triangle t \ge 1$), no judgment effect is produced (equivalent to a meaningless click);
Scenario 2: $0.6 \le \triangle t < 1$, this key produces a miss judgment and disappears;
Scenario 3: $0.2 \le \triangle t < 0.6$, this key produces a good judgment and disappears;
Scenario 4: $-0.2 < \triangle t < 0.2$ (negative means clicking after the key reaches the judgment line), this key produces a perfect judgment and disappears;
Scenario 5: $-0.6 < \triangle t \le -0.2$, this key produces a good judgment and disappears;
Scenario 6: $\triangle t \le -0.6$, the key will fall off the screen before being clicked, producing a miss judgment and disappearing (i.e., the key itself generates a miss judgment 0.6 seconds after falling below the judgment line), the click has no judgment effect on this key.
Additionally, dimou has a maximum combo judgment (max combo). A combo is a sequence of judgments from a non-miss judgment to another non-miss judgment (with no miss judgments in between (in chronological order)), and the total number of judgments in this sequence. The max combo is the highest value among all combos.
Furthermore, dimou has some judgment rules. A click can be considered as a point on the judgment line, and a vertical line is drawn from this point. Only keys that intersect with this vertical line (the intersection can be at the endpoints) can potentially produce a judgment effect from this click. Moreover, each click will only produce a judgment effect on the key that is lowest (farthest from the top of the screen) among those that can potentially produce a judgment effect. Visually, you can only eliminate a key by clicking below it, and if two keys are falling with a vertical distance between them, clicking will only eliminate the lower key, not the upper one. Specifically, if a click potentially produces a judgment effect on two or more keys at the same height and there are no lower keys that can produce a judgment effect, all these keys will be eliminated.
To play a song well, Little K decides to memorize the positions of all keys and their times to reach the judgment line. Of course, Little K also plans his gameplay, deciding when and where to click. However, Little K cannot calculate his final score from his gameplay. Please help Little K calculate how many perfect, good, and miss judgments he will get, as well as the max combo.
Note: Little K will not click twice or more at the same time. If there are multiple judgments at the same time, process them in the order of miss, good, and perfect.
Input Format
The first line contains two positive integers $n, m$, representing the number of keys and the number of clicks by Little K, respectively.
The next $n$ lines, each containing three floating-point numbers (with no more than 5 decimal places) $t_i, a_i, b_i$, represent the time each key reaches the judgment line from the start of the song, its left endpoint position, and its right endpoint position, respectively.
The next $m$ lines, each containing two floating-point numbers (with no more than 5 decimal places) $T_i, x_i$, represent the time and position of each click by Little K from the start of the song.
Output Format
One line, output four non-negative integers separated by single spaces, representing the number of perfect judgments, good judgments, miss judgments, and max combo, respectively.
Sample Input and Output
Sample Input #1
5 6
1 0.0 10.0
1.5 0.0 10.0
2.0 0.0 10.0
2.5 0.0 10.0
3.0 0.0 10.0
0.0 5.0
0.4 5.0
1.3 5.0
2.0 5.0
2.7 5.0
3.6 5.0
Sample Output #1
1 2 2 3
Sample Input #2
4 2
0.1 0.0 3.0
0.1 2.0 4.0
0.0 3.0 8.0
0.6 1.0 6.0
0.6 6.0
0.0 2.5
Sample Output #2
3 0 1 2
Notes/Hints
Sample Explanation
For sample 1: The judgments produced by the 5 keys in chronological order are miss, good, perfect, good, miss. The first and last clicks do not produce any judgment effects.
For sample 2: In chronological order, the first click ($T=0.0$) potentially produces judgment effects on the 1st, 2nd, and 4th keys (in input order). The 1st and 2nd keys reach the judgment line simultaneously, and the 4th key is higher than the 1st and 2nd keys. Therefore, the first click only produces perfect judgments for the 1st and 2nd keys. The second click ($T=0.6$) intersects with the 3rd and 4th keys, but the 3rd key has already produced a miss judgment and disappeared, so this click produces a perfect judgment for the 4th key. At this time, two judgments, perfect and miss, occur simultaneously, and according to the rules, the miss is processed first, followed by the perfect. Therefore, the judgments in chronological order are perfect, perfect, miss, perfect. It is easy to see that the miss divides the judgment sequence into two parts, the first part's combo is 2, and the second part's combo is 1, so the max combo is 2.
Data Range
For 30% of the data, $n, m \le 5000$.
For another 20% of the data, $n \le 5000$, $m \le 114514$.
For another 10% of the data, all $a_i$ are equal, and all $b_i$ are equal.
For another 10% of the data, $t_i, T_i, a_i, b_i, x_i$ are randomly generated within $[0, 10^4]$.
For 100% of the data, $1 \le n, m \le 114514$, $0 \le t_i, T_i, a_i, b_i, x_i \le 10^4$, $a_i \le b_i$.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分