#abc243c. C - Collision 2

C - Collision 2

Score : 300300 points

问题描述

xyxy 平面上有 NN 个人。第 ii 个人位于坐标 (Xi,Yi)(X_i, Y_i),所有人的位置各不相同。

我们有一个长度为 NN 的字符串 SS,由字符 LR 组成。
Si=S_i = R,表示第 ii 个人面向右方;若 Si=S_i = L,则表示第 ii 个人面向左方。所有人同时开始朝他们面对的方向行走。其中,右和左分别对应正和负的 xx 轴方向。

例如,下图展示了当 (X1,Y1)=(2,3)(X_1, Y_1) = (2, 3)(X2,Y2)=(1,1)(X_2, Y_2) = (1, 1)(X3,Y3)=(4,1)(X_3, Y_3) = (4, 1),且 S=S = RRL 时人们的移动情况。

我们称,当两个朝相反方向行走的人到达同一个位置时发生碰撞。如果所有人都无限期地继续行走,会发生碰撞吗?

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There are NN people in an xyxy-plane. Person ii is at (Xi,Yi)(X_i, Y_i). The positions of all people are different.

We have a string SS of length NN consisting of L and R.
If Si=S_i = R, Person ii is facing right; if Si=S_i = L, Person ii is facing left. All people simultaneously start walking in the direction they are facing. Here, right and left correspond to the positive and negative xx-direction, respectively.

For example, the figure below shows the movement of people when $(X_1, Y_1) = (2, 3), (X_2, Y_2) = (1, 1), (X_3, Y_3) =(4, 1), S =$ RRL.

image

We say that there is a collision when two people walking in opposite directions come to the same position. Will there be a collision if all people continue walking indefinitely?

Constraints

  • 2N2×1052 \leq N \leq 2 \times 10^5
  • 0Xi1090 \leq X_i \leq 10^9
  • 0Yi1090 \leq Y_i \leq 10^9
  • (Xi,Yi)(Xj,Yj)(X_i, Y_i) \neq (X_j, Y_j) if iji \neq j.
  • All XiX_i and YiY_i are integers.
  • SS is a string of length NN consisting of L and R.

Input

Input is given from Standard Input in the following format:

NN

X1X_1 Y1Y_1

X2X_2 Y2Y_2

\vdots

XNX_N YNY_N

SS

Output

If there will be a collision, print Yes; otherwise, print No.

Sample Input 1

3
2 3
1 1
4 1
RRL

Sample Output 1

Yes

This input corresponds to the example in the Problem Statement.
If all people continue walking, Person 22 and Person 33 will collide. Thus, Yes should be printed.

Sample Input 2

2
1 1
2 1
RR

Sample Output 2

No

Since Person 11 and Person 22 walk in the same direction, they never collide.

Sample Input 3

10
1 3
1 4
0 0
0 2
0 4
3 1
2 4
4 2
4 4
3 3
RLRRRLRLRR

Sample Output 3

Yes

update @ 2024/3/10 10:27:01

}