Find the maximum (of the function)
You have a field divided into ( n \times m ) squares. Rows are numbered from 1 to n from top to bottom, and columns from 1 to m from left to right. Your robot starts at cell (1, 1).
Each cell contains a specific number. The robot can only see the number in the cell it currently occupies. It can move left, right, down, and up, but it doesn't know the dimensions of the field.
Your task is to find the maximum number on the field using the robot.
Interaction
You need to implement the following function:
integer solve()
This function should return a single integer — the maximum number on the field.
You can use these functions:
integer getValue()
Returns the integer in the cell where the robot is currently located.
boolean canMoveLeft()
boolean canMoveRight()
boolean canMoveUp()
boolean canMoveDown()
Each function returns true if the robot can move in the specified direction without going out of bounds, otherwise false.
void moveLeft()
void moveRight()
void moveUp()
void moveDown()
Each function moves the robot one cell in the specified direction.
Input Format
The first line contains two integers n and m ((1 \leq n, m \leq 100)) — the dimensions of the field.
Each of the next n rows contains m integers ( a[i1], a[i2], \ldots, a[im] ) ((0 \leq |a[ij]| \leq 10^9)) — the numbers on the field.
Output Format
Output a single integer — the maximum number on the field.
Example:
Let ( n = 2 ), ( m = 3 ), and
( a = )
1 3 4
8 1 5
If the robot is at cell (1, 1), the functions canMoveLeft and canMoveUp will return false, while canMoveRight and canMoveDown will return true. Calling getValue at that position will return 1.
If you call moveDown, the robot will move to position (2, 1). Then, canMoveDown will return false, and getValue will return 8.
Note: The example illustrates how to use the functions, not how to solve the problem.
Scoring:
(up to 50 points) ( n \leq 1 );
Let ( c ) be the minimum number of moves needed to definitely find the answer, and ( t ) be the maximum number of moves you made in all tests. You will score (\max(\lfloor 50 - \sqrt{t - c} \rfloor, 0)) points.
(up to 50 points) without additional restrictions;
Let ( c ) be the minimum number of moves needed to definitely find the answer, and ( t ) be the maximum number of moves you made in all tests. You will score (\max(\lfloor 50 - (1/3.0)^{(t-c)} \rfloor, 0)) points.