Board Coloring and Query Processing
Consider a rectangular h × w board with all cells initially white. You are to process several queries of the following types:
- "x a b" - color the white cell (a, b) (0-based coordinates, the first one is a row index, and the second one is a column index) black;
- "> a b" - find the leftmost white cell to the right of the white cell (a, b);
- "< a b" - find the rightmost white cell to the left of the white cell (a, b);
- "v a b" - the same, but the search should be done downwards;
- "^ a b" - the same, but the search should be done upwards;
For each query, except the ones of the first type, find the answer.
For each query except the ones of the first type, store the answer's coordinates in the array. If the desired cell doesn't exist, store [-1, -1] instead. The answers should be stored in the same order as the queries.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
