

Time Limit: 2 sec / Memory Limit: 512 MB
配点 : 点
問題文
二次元平面の原点にロボットが置かれています。 最初、ロボットは 軸の正の向きを向いています。
このロボットに命令列 が与えられます。 は次の 文字のみからなり、先頭から末尾まで順に実行されます。
F
: 今向いている向きに長さ だけ移動する。T
: 時計回りまたは反時計回りの好きな方向に 度だけ向きを変える。
ロボットの目標は、命令列をすべて実行し終わった後に座標 にいることです。 この目標が達成可能か判定してください。
制約
- は
F
,T
のみからなる。 - , は整数である。
入力
入力は以下の形式で標準入力から与えられる。
出力
目標が達成可能ならば Yes
を出力し、達成不可能ならば No
を出力せよ。
入力例 1Copy
FTFFTFFF 4 2
出力例 1Copy
Yes
番目の T
で反時計周りに 度だけ向きを変え、 番目の T
で時計周りに 度だけ向きを変えればよいです。
入力例 2Copy
FTFFTFFF -2 -2
出力例 2Copy
Yes
番目の T
で時計周りに 度だけ向きを変え、 番目の T
で時計周りに 度だけ向きを変えればよいです。
入力例 3Copy
FF 1 0
出力例 3Copy
No
入力例 4Copy
TF 1 0
出力例 4Copy
No
入力例 5Copy
FFTTFF 0 0
出力例 5Copy
Yes
例えば、 番目の T
で反時計周りに 度だけ向きを変え、 番目の T
で反時計周りに 度だけ向きを変えればよいです。
入力例 6Copy
TTTT 1 0
出力例 6Copy
No
Score : points
Problem Statement
A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive -axis direction.
This robot will be given an instruction sequence . consists of the following two kinds of letters, and will be executed in order from front to back.
F
: Move in the current direction by distance .T
: Turn degrees, either clockwise or counterclockwise.
The objective of the robot is to be at coordinates after all the instructions are executed. Determine whether this objective is achievable.
Constraints
- consists of
F
andT
. - and are integers.
Input
Input is given from Standard Input in the following format:
Output
If the objective is achievable, print Yes
; if it is not, print No
.
Sample Input 1Copy
FTFFTFFF 4 2
Sample Output 1Copy
Yes
The objective can be achieved by, for example, turning counterclockwise in the first T
and turning clockwise in the second T
.
Sample Input 2Copy
FTFFTFFF -2 -2
Sample Output 2Copy
Yes
The objective can be achieved by, for example, turning clockwise in the first T
and turning clockwise in the second T
.
Sample Input 3Copy
FF 1 0
Sample Output 3Copy
No
Sample Input 4Copy
TF 1 0
Sample Output 4Copy
No
Sample Input 5Copy
FFTTFF 0 0
Sample Output 5Copy
Yes
The objective can be achieved by, for example, turning counterclockwise in the first T
and turning counterclockwise in the second T
.
Sample Input 6Copy
TTTT 1 0
Sample Output 6Copy
No