atcoder#ABC243C. [ABC243C] Collision 2

[ABC243C] Collision 2

Score : 300300 points

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.

3
2 3
1 1
4 1
RRL
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.

2
1 1
2 1
RR
No

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

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