Blackflopper inc™️ have begun a new space exploratory program! Their first unit, the Spadunk-00, has now reached orbit around a planet.
Spadunk-00's onboard data transformation system represents its current position in terms of the planet. In other words, the planet will be the origin of a coordinate system, and Spadunk-00's position can be represented as a 2-d coordinate .
Spadunk-00 works in a peculiar way. The engineers send a series of commands, all of which either adds a line to the onboard program in Spadunk-00, or executes the program. Prior to the first command issued, the program on Spadunk-00 is empty. Each command can be one of three types:
move(x, y)
- adds an instruction to the onboard program. When Spadunk-00 runs the program (which occurs when it runs the execute() command), the instruction this command adds moves Spadunk-00 by
blast(v)
- adds an instruction to the onboard program. When Spadunk-00 runs the program (which occurs when it runs the execute() command), the instruction this command adds blasts Spadunk-00 away from or towards the planet, so that it is now times as far from the planet (which is the origin). In other words, it multiplies both the x coordinate and y coordinate by .Note that move(x, y) and blast(v), by themselves, do nothing. However, they add an instruction to Spadunk-00's program, which, when run through the execute() method, would update its position.
execute()
- runs the program, executing each instruction which was stored in Spadunk-00 through the move() and blast() commands. The program is run sequentially, running each instruction starting from the earliest added to the latest, thus updating the position of Spadunk-00. All of the lines that were previously on Spadunk-00's program will remain in the program.
Unfortunately, the engineers soon realized that the whiteflipper nation have intercepted their signal and provided Spadunk-00 with commands already! Can you, Spock, find out the final coordinates of the Spadunk-00?
Constraints
In all subtasks,
.
At any point in time, the absolute value of Spadunk-00's x coordinate and y coordinate will not exceed .
Subtask 1 [10%]
.
Subtask 2 [30%]
. In other words, at any point in time, Spadunk-00's y-coordinate will be 0.
Subtask 3 [60%]
No additional constraints.
Input Specification
The first line contains two decimals, and , representing the current coordinates of Spadunk-00.
The second line contains a nonnegative integer, , representing the number of commands that the Whiteflipper nation sent to Spadunk-00.
The next lines are in one of the following formats:
1 x y
- the whiteflipper nation sends themove(x, y)
command to Spadunk-00. and are decimals with absolute values less than .
2 v
- the whiteflipper nation sends theblast(v)
command to Spadunk-00. is a decimal with absolute value less than .
3
- the whiteflipper nation sends theexecute()
command to Spadunk-00.
Output Specification
Two decimals on one line, the x and y coordinate of Spadunk-00 after it runs all of the commands. Only when printing the final answer, round the x and y coordinates to the nearest hundredth, printing out two digits after the decimal point. It is recommended to use double instead of float due to precision differences.
Sample Input
3.0 4.0
6
1 2.0 3.0
2 2.0
3
1 -2.0 5.0
2 0.5
3
Sample Output
11.00 19.50
Sample Explanation
After the first and second commands, the program is:
move(2.0, 3.0)
blast(2.0)
The third command executes this program, the coordinates are updated as such:
move(2.0, 3.0)
: ->
blast(2.0)
: ->
The fourth and fifth command add two more commands. Now, our program is:
move(2.0, 3.0)
blast(2.0)
move(-2.0, 5.0)
blast(0.5)
The final command executes the program once more. The coordinates are updated as such:
move(2.0, 3.0)
: ->
blast(2.0)
: ->
move(-2.0, 5.0)
: ->
blast(0.5)
: ->
Thus, our final coordinate is . When printing your final answer, remember to round to the nearest hundredth and print out two decimal places. Thus, we print out 11.00 19.50
Comments