

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 300 点
問題文
xy 座標平面上に N 人の人がいます。人 i は (X_i, Y_i) にいます。すべての人は異なる地点にいます。
L
, R
からなる長さ N の文字列 S があります。
人 i は S_i = R
ならば右向きに、S_i = L
ならば左向きに、一斉に同じ速度で歩き始めます。ここで、右は x 軸の正の向き、左は x 軸の負の向きです。
たとえば (X_1, Y_1) = (2, 3), (X_2, Y_2) = (1, 1), (X_3, Y_3) =(4, 1), S = RRL
の場合は次の図のように動きます。
反対の向きに歩いている人同士が同じ地点に来ることを「衝突」と呼びます。すべての人が歩き続けたとき、衝突は発生しますか?
制約
- 2 \leq N \leq 2 \times 10^5
- 0 \leq X_i \leq 10^9
- 0 \leq Y_i \leq 10^9
- i \neq j ならば (X_i, Y_i) \neq (X_j, Y_j) である。
- X_i, Y_i はすべて整数である。
- S は
L
およびR
からなる長さ N の文字列である。
入力
入力は以下の形式で標準入力から与えられる。
N X_1 Y_1 X_2 Y_2 \vdots X_N Y_N S
出力
衝突が発生するならば Yes
を、発生しないならば No
を出力せよ。
入力例 1
3 2 3 1 1 4 1 RRL
出力例 1
Yes
この入力は問題文にある例と同じケースです。
すべての人が歩き続けると人 2 と人 3 が衝突します。よって Yes
を出力します。
入力例 2
2 1 1 2 1 RR
出力例 2
No
人 1 と人 2 は同じ向きに歩いているので衝突することはありません。
入力例 3
10 1 3 1 4 0 0 0 2 0 4 3 1 2 4 4 2 4 4 3 3 RLRRRLRLRR
出力例 3
Yes
Score : 300 points
Problem Statement
There are N people in an xy-plane. Person i is at (X_i, Y_i). The positions of all people are different.
We have a string S of length N consisting of L
and R
.
If S_i = R
, Person i is facing right; if S_i = L
, Person i is facing left. All people simultaneously start walking in the direction they are facing. Here, right and left correspond to the positive and negative x-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
.
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
- 2 \leq N \leq 2 \times 10^5
- 0 \leq X_i \leq 10^9
- 0 \leq Y_i \leq 10^9
- (X_i, Y_i) \neq (X_j, Y_j) if i \neq j.
- All X_i and Y_i are integers.
- S is a string of length N consisting of
L
andR
.
Input
Input is given from Standard Input in the following format:
N X_1 Y_1 X_2 Y_2 \vdots X_N Y_N S
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 2 and Person 3 will collide. Thus, Yes
should be printed.
Sample Input 2
2 1 1 2 1 RR
Sample Output 2
No
Since Person 1 and Person 2 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