#C1014. Robot Final Position
Robot Final Position
Robot Final Position
You are given a robot that starts at the origin \((0, 0)\) on a Cartesian plane. The robot can receive a series of commands to move in the plane. The commands are as follows:
- UP d: Move up by \(d\) units (increase the \(y\) coordinate).
- DOWN d: Move down by \(d\) units (decrease the \(y\) coordinate).
- LEFT d: Move left by \(d\) units (decrease the \(x\) coordinate).
- RIGHT d: Move right by \(d\) units (increase the \(x\) coordinate).
- JUMP x y: Teleport directly to the point \((x, y)\).
When a JUMP
command is issued, it immediately overrides any previous position and sets the robot's location to the specified coordinates. Your task is to determine the final coordinates of the robot after processing all commands.
inputFormat
The input begins with a single integer \(n\) (\(1 \leq n \leq 1000\)), representing the number of commands. Each of the following \(n\) lines contains one command. The commands are in one of the following formats:
UP d
DOWN d
LEFT d
RIGHT d
JUMP x y
Here, \(d\), \(x\), and \(y\) are integers. You may assume that the absolute values of these integers do not exceed \(10^9\).
outputFormat
Output the final \(x\) and \(y\) coordinates separated by a space.
## sample1
UP 10
0 10