Problem · Matrix
Board Coloring and Query Processing
Learn this problemProblem statement
Consider a rectangular h × w board with all cells initially white. You are to process several queries of the following types:
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.
Function
solution(h: int, w: int, queries: String[]) → int[][]Examples
Example 1
h = 3w = 5queries = ["v 1 2", "x 2 2", "v 1 2", "> 2 1", "x 2 3", "> 2 1", "< 2 0"]return = [[2, 2], [-1, -1], [2, 3], [2, 4], [-1, -1]]:3
Constraints
1 ≤ h ≤ 500.1 ≤ w ≤ 500.5 ≤ queries.length ≤ 10^4 (OR MAYBE 104).