GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Friday 26 August 2022

[Solution] Wiggle Walk Kick Start Session Solution - Kick Start 2022


Banny has just bought a new programmable robot. Eager to test his coding skills, he has placed the robot in a grid of squares with R rows (numbered 1 to R from north to south) and C columns (numbered 1 to C from west to east). The square in row r and column c is denoted (r,c).

Initially the robot starts in the square (SRSC). Banny will give the robot N instructions. Each instruction is one of NSE, or W, instructing the robot to move one square north, south, east, or west respectively.

If the robot moves into a square that it has been in before, the robot will continue moving in the same direction until it reaches a square that it has not been in before. Banny will never give the robot an instruction that will cause it to move out of the grid.

Can you help Banny determine which square the robot will finish in, after following the N instructions?

Input

The first line of the input gives the number of test cases, TT test cases follow. Each test case starts with a line containing the five integers NRCSR, and SC, the number of instructions, the number of rows, the number of columns, the robot's starting row, and the robot's starting column, respectively.

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

Then, another line follows containing a single string consisting of N characters; the i-th of these characters is the i-th instruction Banny gives the robot (one of NSE, or W, as described above).

Output

For each test case, output one line containing Case #xr c, where x is the test case number (starting from 1), r is the row the robot finishes in, and c is the column the robot finishes in.

Limits

Memory limit: 1 GB.
1T100.
1R5×104.
1C5×104.
1SRR.
1SCC.
The instructions will not cause the robot to move out of the grid.

Test Set 1

Time limit: 20 seconds.

1N100.

Test Set 2

Time limit: 60 seconds.

1N5×104.

No comments:

Post a Comment