Problem Description

You have a grid of size r x c. Start at (sr, sc). You get a command string of U, D, L, R. If a move goes outside grid, ignore it and count it as blocked. Output final position and blocked count.

Input Format

Line1: r c. Line2: sr sc. Line3: commands.

Output Format

One line: finalR finalC blocked.

Sample Test Case

Input:
3 4 1 1 UURRDDL
Output:
0 3 1

Constraints

0

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next