题目描述
Problem Description
A robot is placed at point \( (0,0) \) on the \( xy \)-plane. You can give this robot a string consisting of L, R, U, D as an instruction. When given the string, the robot will move according to the characters in the string, starting from the first character: L means moving \( -1 \) in the \( x \)-axis direction, R means moving \( +1 \) in the \( x \)-axis direction, U means moving \( +1 \) in the \( y \)-axis direction, and D means moving \( -1 \) in the \( y \)-axis direction, until the last character is processed.
You have a string \( S \) consisting of W, X, Y, Z. You are trying to replace these four types of characters with either L, R, U, or D to form a string to give to the robot. However, different characters in \( S \) cannot be assigned the same character in the instruction.
You are given a string \( S \) and integers \( g_x \), \( g_y \). Determine if it is possible, through appropriate character assignments, for the robot to pass through the coordinate \( (g_x, g_y) \) at any point from the start to the end of its movement (including the start and end points). If possible, output Yes; otherwise, output No.
Input Format
The input is given from the standard input in the following format:
\( S \) \( g_x \) \( g_y \)
Output Format
Output Yes if it is possible for the robot to pass through the coordinate \( (g_x, g_y) \) at any point from the start to the end of its movement (including the start and end points) through appropriate character assignments. Otherwise, output No.
Sample Input and Output
Sample Input #1
WWYWYWWW
3 0
Sample Output #1
Yes
Sample Input #2
YYYYW
-1 -3
Sample Output #2
No
Sample Input #3
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
0 50
Sample Output #3
Yes
Notes/Hints
Constraints
- \( 1 \leq |S| \leq 10^5 \)
- \( S \) is a string consisting of
W,X,Y,Z - \( |g_x|, |g_y| \leq 10^5 \)
- \( g_x \), \( g_y \) are integers
Sample Explanation 1
For example, by assigning W to R, X to U, Y to L, and Z to D, it is possible to pass through \( (3,0) \).
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分