atcoder#ABC243C. [ABC243C] Collision 2
[ABC243C] Collision 2
Score : points
Problem Statement
There are people in an -plane. Person is at . The positions of all people are different.
We have a string of length consisting of L
and R
.
If R
, Person is facing right; if L
, Person is facing left. All people simultaneously start walking in the direction they are facing. Here, right and left correspond to the positive and negative -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
- if .
- All and are integers.
- is a string of length consisting of
L
andR
.
Input
Input is given from Standard Input in the following format:
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 and Person will collide. Thus, Yes
should be printed.
2
1 1
2 1
RR
No
Since Person and Person 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