D. Fall Guys

Codeforces
IDCF10280D
Time4000ms
Memory64MB
Difficulty
English · Original
Formal · Original
$textit(F a l l G u y s)$ is a recently popular game. There are at most 60 players participating in a game and only one player will win finally after passing through one level after another. $textit(F a l l G u y s)$ has a level named climbing competition. Players will reach the destination after crossing many obstacles. After reaching the destination, they have to grab the crown to be the winner. But the crown moves up and down, and the player can catch it when the crown is below $h$ m. Now, there are $n$ players participating in the climbing competition level. The height of the crown is $0$ at the beginning of the game, and then the crown will move up at a speed of $1$ m/s. When the height increases to $H$ m, the crown will immediately move down at a speed of $1$ m/s until the height decreases to $0$, and then move up and move down repeatedly. The time that the $i$-th player reaches the destination is $x_i$. When a player reaches the destination, if the height of the crown is greater than $h$ m he will wait in place, otherwise he will immediately jump and grab the crown. However, each player has a delay time $c_i$ because of the bad network. Assuming that a player grab the crown at the moment of $t$ s, the system will determine that the moment he grab the crown is $(t + c_i)$ s. The first player who grab the crown will win. If multiple players grab the crown at the same time, the winner is the player with the lower number. You are given the arrival time $x_i$ and the delay time $c_i$ of all players, please calculate who will be the final winner. The input consists of multiple test cases. The first line contains an integer $T$ $(1 <= T <= 20)$ — the number of test cases. The description of the test cases follows. The first line contains three integers $n, h, H$ $(1 <= n <= 2 * 10^5, 1 <= h <= H <= 300)$. The second line contains $n$ integers $x_1, x_2, \\dots, x_n (1 <= x_i <= 2 * 10^5)$ — the arrival time of the $i$-th player. The third line contains $n$ integers $c_1, c_2, \\dots, c_n (1 <= c_i <= 2 * 10^5)$ — the delay time of the $i$-th player. For each test case, print the winner. ## Input The input consists of multiple test cases. The first line contains an integer $T$ $(1 <= T <= 20)$ — the number of test cases. The description of the test cases follows.The first line contains three integers $n, h, H$ $(1 <= n <= 2 * 10^5, 1 <= h <= H <= 300)$.The second line contains $n$ integers $x_1, x_2, \\dots, x_n (1 <= x_i <= 2 * 10^5)$ — the arrival time of the $i$-th player.The third line contains $n$ integers $c_1, c_2, \\dots, c_n (1 <= c_i <= 2 * 10^5)$ — the delay time of the $i$-th player. ## Output For each test case, print the winner. [samples]
**Definitions** Let $ a, b, c \in \mathbb{Z}^+ $, $ A, B, C \in \mathbb{Z} $, with $ |A| + |B| + |C| > 0 $. Let $ \mathcal{C} = [0, a] \times [0, b] \times [0, c] $ be the axis-aligned cuboid with opposite vertices $ (0,0,0) $ and $ (a,b,c) $. Let $ \mathcal{P}_D: Ax + By + Cz + D = 0 $ be a plane intersecting $ \mathcal{C} $, where $ D \in \mathbb{R} $ is uniformly random such that $ \mathcal{P}_D \cap \mathcal{C} \neq \emptyset $. **Constraints** The set of valid $ D $ is the interval $ [D_{\min}, D_{\max}] $, where: $$ D_{\min} = -\max_{(x,y,z) \in \mathcal{C}} (Ax + By + Cz), \quad D_{\max} = -\min_{(x,y,z) \in \mathcal{C}} (Ax + By + Cz) $$ and $ D_{\min} < D_{\max} $ (since the plane intersects the cuboid). **Objective** For each $ D \in (D_{\min}, D_{\max}) $, the intersection $ \mathcal{P}_D \cap \mathcal{C} $ is a convex polygon whose number of edges $ e(D) \in \{3,4,5,6\} $. Let $ P_1, P_2, P_3, P_4 $ be the probabilities that $ e(D) = 3, 4, 5, 6 $ respectively, under uniform distribution of $ D $ over $ (D_{\min}, D_{\max}) $. Compute $ P_1, P_2, P_3, P_4 \mod 10^9 + 7 $ as rational numbers $ Q_i \cdot P_i^{-1} \mod 10^9 + 7 $, where each $ P_i = \frac{Q_i}{L} $ for $ L = D_{\max} - D_{\min} $, and $ Q_i $ is the length of the subinterval of $ D $ yielding $ e(D) = i $. **Note**: The number of edges of the cross-section depends on how many of the 12 edges of the cuboid the plane intersects, which is determined by the sign pattern of $ Ax + By + Cz + D $ at the 8 vertices. The transition between 3,4,5,6 edges occurs at critical $ D $ values where the plane passes through a vertex. There are at most 8 such critical values, partitioning $ (D_{\min}, D_{\max}) $ into at most 9 intervals, each with constant edge count. The probabilities $ P_1, P_2, P_3, P_4 $ are proportional to the total length of intervals where the cross-section has 3, 4, 5, or 6 edges respectively.
API Response (JSON)
{
  "problem": {
    "name": "D. Fall Guys",
    "description": {
      "content": "$textit(F a l l G u y s)$ is a recently popular game. There are at most 60 players participating in a game and only one player will win finally after passing through one level after another.  $textit",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 4000,
      "memory_limit": 65536
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10280D"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "$textit(F a l l G u y s)$ is a recently popular game. There are at most 60 players participating in a game and only one player will win finally after passing through one level after another. \n\n$textit...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ a, b, c \\in \\mathbb{Z}^+ $, $ A, B, C \\in \\mathbb{Z} $, with $ |A| + |B| + |C| > 0 $.  \nLet $ \\mathcal{C} = [0, a] \\times [0, b] \\times [0, c] $ be the axis-aligned cuboid with...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments