atcoder#ABC244B. [ABC244B] Go Straight and Turn Right
[ABC244B] Go Straight and Turn Right
Score : points
Problem Statement
Consider an -plane. The positive direction of the -axis is in the direction of east, and the positive direction of the -axis is in the direction of north. Takahashi is initially at point and facing east (in the positive direction of the -axis).
You are given a string of length consisting of S
and R
.
Takahashi will do the following move for each in this order.
- If
S
, Takahashi advances in the current direction by distance . - If
R
, Takahashi turns degrees clockwise without changing his position. As a result, Takahashi's direction changes as follows.- If he is facing east (in the positive direction of the -axis) before he turns, he will face south (in the negative direction of the -axis) after he turns.- If he is facing south (in the negative direction of the -axis) before he turns, he will face west (in the negative direction of the -axis) after he turns.
- If he is facing west (in the negative direction of the -axis) before he turns, he will face north (in the positive direction of the -axis) after he turns.
- If he is facing north (in the positive direction of the -axis) before he turns, he will face east (in the positive direction of the -axis) after he turns.
Print the coordinates Takahashi is at after all the steps above have been done.
Constraints
- is an integer.
- is a string of length consisting of
S
andR
.
Input
Input is given from Standard Input in the following format:
Output
Print the coordinates Takahashi is at after all the steps described in the Problem Statement have been completed, in the following format, with a space in between:
4
SSRS
2 -1
Takahashi is initially at facing east. Then, he moves as follows.
-
S
, so he advances in the direction of east by distance , arriving at . -
S
, so he advances in the direction of east by distance , arriving at . -
R
, so he turns degrees clockwise, resulting in facing south. -
S
, so he advances in the direction of south by distance , arriving at .
Thus, Takahashi's final position, , should be printed.
20
SRSRSSRSSSRSRRRRRSRR
0 1