問題一覧 > 通常問題

No.2564 Collision Prediction

レベル : / AI推定難易度 : 700 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 150
作問者 : Magentor / テスター : deuteridayo 👑 AngrySadEight Kyo_s_s kusirakusira 👑 loop0919 rotti_coder ragna マベマス(mavemas_413) けんぴん aki
お気に入りにしたユーザー ProblemId : 10333 / 自分の提出
問題文最終更新日: 2023-12-01 15:27:56
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
第2回緑以下コンテスト (順位表) の他の問題:

Problem Statement

You are given $T$ cases. Solve the following problem for each of them.

There are $2$ cars on the $xy$-plane. The coordinates of the $i$-th car are $(x_i,y_i)$. Each car now starts moving at a speed of $1$ per second. Here, the $i$-th car moves in the following direction.

  • If $d_i=$ R, the positive direction of the $x$-axis
  • If $d_i=$ L, the negative direction of the $x$-axis
  • If $d_i=$ U, the positive direction of the $y$-axis
  • If $d_i=$ D, the negative direction of the $y$-axis
If the $2$ cars are at the same coordinates at some time, the $2$ cars are said to have collided. Determine whether the $2$ cars will collide.

Constraints

  • $T, x_1, y_1, x_2, y_2$ are integers
  • $1 \leq T \leq 10^5$
  • $-10^9 \leq x_1,y_1,x_2,y_2 \leq 10^9$
  • $(x_1,y_1) ≠ (x_2,y_2)$
  • $d_1,d_2$ are each one of R,L,U,D

Input

The input is given from standard input in the following format. Here, $\text{case}_i$ denotes the $i$-th test case.

$T$
$\text{case}_1$
$\text{case}_2$
$\vdots$
$\text{case}_T$

Each test case is given in the following format.

$x_1\ y_1 \ d_1$
$x_2 \ y_2 \ d_2$

Output

Print $T$ lines. On the $i$-th line, print Yes if the $2$ cars collide in the $i$-th test case, and No otherwise.

Sample

Sample 1
Input
2
1 1 U
1 5 D
3 2 U
5 4 L
Output
Yes
Yes
  • In the $1$-st test case, a collision occurs at $(1,3)$ after $2$ seconds.
  • In the $2$-nd test case, a collision occurs at $(3,4)$ after $2$ seconds.
Sample 2
Input
1
1 2 L
3 4 D
Output
No
Sample 3
Input
3
998244353 0 U
0 998244353 R
998244353 998244353 U
0 0 D
0 0 R
998244353 0 L
Output
Yes
No
Yes

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。