Score : $200$ points
Consider an $xy$-plane. The positive direction of the $x$-axis is in the direction of east, and the positive direction of the $y$-axis is in the direction of north.
Takahashi is initially at point $(x, y) = (0, 0)$ and facing east (in the positive direction of the $x$-axis).
You are given a string $T = t_1t_2\ldots t_N$ of length $N$ consisting of S
and R
.
Takahashi will do the following move for each $i = 1, 2, \ldots, N$ in this order.
S
, Takahashi advances in the current direction by distance $1$.R
, Takahashi turns $90$ degrees clockwise without changing his position. As a result, Takahashi's direction changes as follows.Print the coordinates Takahashi is at after all the steps above have been done.
S
and R
.Input is given from Standard Input in the following format:
$N$ $T$
Print the coordinates $(x, y)$ Takahashi is at after all the steps described in the Problem Statement have been completed, in the following format, with a space in between:
$x$ $y$
4 SSRS
2 -1
Takahashi is initially at $(0, 0)$ facing east. Then, he moves as follows.
S
, so he advances in the direction of east by distance $1$, arriving at $(1, 0)$.S
, so he advances in the direction of east by distance $1$, arriving at $(2, 0)$.R
, so he turns $90$ degrees clockwise, resulting in facing south.S
, so he advances in the direction of south by distance $1$, arriving at $(2, -1)$.Thus, Takahashi's final position, $(x, y) = (2, -1)$, should be printed.
20 SRSRSSRSSSRSRRRRRSRR
0 1