#K90842. Robot Position on an N x N Grid
Robot Position on an N x N Grid
Robot Position on an N x N Grid
You are given an \(n \times n\) grid and a robot that starts at the top-left corner \((0, 0)\). The robot receives a sequence of commands and executes them one by one. Each command is one of the following: 'L' for left, 'R' for right, 'U' for up, and 'D' for down. When attempting to move, if the robot would step outside the grid, it remains in its current position.
Your task is to determine the final coordinates \((x, y)\) of the robot after executing all commands. The coordinates start at 0, so the valid indices on both axes are from 0 to \(n-1\). For example, if the robot is at \((0, 0)\) and receives a command 'U' or 'L', it stays at \((0, 0)\) because it cannot move further up or left.
inputFormat
The input consists of two lines:
- The first line contains an integer \(n\), representing the size of the grid (i.e., the grid is \(n \times n\)).
- The second line contains a string of characters (each being 'L', 'R', 'U', or 'D') indicating the movement commands. The string may be empty.
outputFormat
Output the final position of the robot as two space-separated integers \(x\) and \(y\) indicating its coordinates on the grid.
## sample5
0 0