#P1724. 东风谷早苗
东风谷早苗
Description
In Gensokyo, Sanae Kochiya is a high school otaku shrine maiden known as a Gundam superfan. One day, she finally got her hands on the latest Gundam model. As the newest Gundam, of course it has a new feature: it can walk automatically. Impressive, right (okay, I’ll behave). Sanae’s new model can move according to the input commands. The commands are , , , , corresponding to the four directions: east, south, west, and north, respectively. When executing a command, it moves one unit in the corresponding direction. As a new type of robot, it can execute a command string rather than a single command. For the input command string, it executes one command per second. After finishing the last command in the string, it automatically loops back to the beginning. At time , Sanae places the Gundam at position and inputs the command string. She wants to know the coordinates of the Gundam after seconds.
Assume the current position of the Gundam is . For moves in the four directions, its coordinates change as follows:
- Move east: the coordinates change to .
- Move south: the coordinates change to .
- Move west: the coordinates change to .
- Move north: the coordinates change to .
Input Format
The first line contains a string , the command string Sanae inputs, which is guaranteed to contain at least command. The second line contains a positive integer .
Output Format
Output two integers on one line, the coordinates of the Gundam at time seconds.
NSWWNSNEEWN
12
-1 3
Hint
Let denote the length of the command string Sanae inputs.
- For of the testdata, , .
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号