Find That Area
There is a rectangular grid that consists of W x H square cells. I stand on one of the cells and simulate the following steps:
• Initially, I am facing east.
• I move in steps. In each step I move to the adjacent cell in the direction I am currently facing.
• I can not leave the grid.
• I do not visit the same cell twice.
• If a step forward does not cause me to break the above rules, I take the step.
• Otherwise, I rotate 90 degrees to the left (counter-clockwise) and check whether a step forward still breaks the above rules. If not, I take the step and continue executing this program (still rotated in the new direction).
• If the rotation left did not help, I terminate the execution of this program.
• I may also terminate the execution of the program manually, at any moment.
I forgot the dimensions of the grid and the original (x,y) coordinates of the cell on which the I was originally standing, but I do remember its movement.
You are given a vector
The first line contains T: the number of test cases.
For each test case there is a single line containing N, the size of vector moves followed by elements of move.
For each test case output on a different line the minimum area if possible or -1 if impossible.
Each element of moves is less than 60.
The number of elements in moves is less than 60.
2 3 10
4 1 1 1 1
4 8 6 6 1
1. Place the robot in a 4*11 board.
2. Impossible sequence of moves.
3. Impossible sequence of moves.
Problem Setter:Shradha Chhaparia