#P5819. dimou Rhythm Game Scoring

    ID: 19047 Type: Default 1000ms 256MiB

dimou Rhythm Game Scoring

dimou Rhythm Game Scoring

In the rhythm game dimou, keys (hit objects) fall vertically towards a judgment line at the bottom of the screen. Each key is represented as a horizontal segment defined by its left and right x‐coordinates, and it reaches the judgment line at time \(t_{key}\). A player makes clicks at specific times and positions on the judgment line in an attempt to hit these keys. However, not every click produces a judgment.

When a click occurs at time \(t\) with x-coordinate \(x\), the following rules are used to determine if and how it affects a key:

  • Only keys whose horizontal segment covers \(x\) (i.e. if a key covers \([L, R]\) then it is eligible if \(L \le x \le R\)) can possibly be affected.
  • If multiple keys are eligible, only the key (or keys) with the lowest vertical position (i.e. the one with the maximum value of \(y = t-t_{key}\)) is affected. (Note: a higher \(y\) means the key has fallen further; keys that have passed the judgment line have \(y \ge 0\) and those that have not yet reached it have \(y < 0\)). If there is a tie (multiple keys with equal \(t_{key}\)), all such keys are hit.

Let \(\Delta t = t_{key} - t\). The judgment for a key caused by a click is determined as follows:

  • Case 1: If \(\Delta t \ge 1\), the click is too early; no judgment is produced.
  • Case 2: If \(0.6 \le \Delta t < 1\), the key receives a miss judgment and disappears.
  • Case 3: If \(0.2 \le \Delta t < 0.6\), the key receives a good judgment and disappears.
  • Case 4: If \(-0.2 < \Delta t < 0.2\), the key receives a perfect judgment and disappears.
  • Case 5: If \(-0.6 < \Delta t \le -0.2\), the key receives a good judgment and disappears.
  • Case 6: If \(\Delta t \le -0.6\), the key will have already fallen off the screen. It automatically produces a miss judgment exactly at time \(t_{key}+0.6\) (and any click at that time or later has no effect on it).

If several judgments occur at the same moment (for example, one click causing multiple keys to be judged, or an auto miss and a click happening simultaneously), they are processed in the following order: miss first, then good, and finally perfect.

A combo is defined as a sequence of consecutive non-miss judgments (processed in time order). The max combo is the maximum number of judgments in any such sequence.

Your task is to simulate a play of dimou given the details of the keys and the player’s clicks, and determine the number of perfect, good, and miss judgments as well as the maximum combo achieved.

Input Format: The first line contains two integers \(n\) and \(m\) denoting the number of keys and the number of clicks respectively. The following \(n\) lines each contain three numbers: \(L\) \(R\) \(t_{key}\) where \(L\) and \(R\) specify the horizontal range of a key and \(t_{key}\) is the time when the key aligns with the judgment line. The next \(m\) lines each contain two numbers: \(t\) and \(x\) representing a click at time \(t\) at horizontal position \(x\).

Output Format: Output four integers separated by a space representing the total number of perfect, good, and miss judgments, and the maximum combo achieved, in that order.

Note: It is guaranteed that no two clicks occur at the same time.

inputFormat

The input begins with two integers \(n\) and \(m\) \( (1 \le n, m \le 10^5)\) indicating the number of keys and clicks respectively. Then follow \(n\) lines, each with three numbers: \(L\), \(R\) (the horizontal interval of the key) and \(t_{key}\) (the time at which the key reaches the judgment line). After that, there are \(m\) lines, each with two numbers: \(t\) (the time of the click) and \(x\) (the x-coordinate of the click).

All times are given as floating-point numbers. It is guaranteed that no two clicks occur at the same time.

outputFormat

Output four space‐separated integers: the number of perfect, good, and miss judgments, and the maximum combo achieved.

sample

2 3
1 3 5.0
2 4 7.0
4.0 2.5
5.1 2.0
7.1 3.0
1 0 1 1