#K43142. Simulate Robot Movement on a 2D Grid
Simulate Robot Movement on a 2D Grid
Simulate Robot Movement on a 2D Grid
Problem Description:
Given an initial position ((x, y)) on a 2D grid and a sequence of movement instructions, simulate the motion of a robot. Each instruction is represented by one of the characters 'U' (move up), 'D' (move down), 'L' (move left), or 'R' (move right). Each move changes the corresponding coordinate by 1 unit.
Your task is to calculate the final position ((x_f, y_f)) of the robot after executing all instructions.
inputFormat
Input Format:
The first line contains two integers, x and y, which represent the initial coordinates of the robot. The second line contains a string consisting solely of the characters 'U', 'D', 'L', and 'R' which corresponds to the movement instructions. Note that the instruction string may be empty.
outputFormat
Output Format:
Output the final x and y coordinates separated by a single space.## sample
3 4
3 4