Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ would be perfect. You are given two numbers n and m representing the dimensions of an n m rectangular board. The rows of the

C++ would be perfect.

You are given two numbers n and m representing the dimensions of an n m rectangular board. The rows of the board are numbered from 1 to n, and the columns are numbered from 1 to m. Each cell has a value equal to the product of its row index and column index (both 1-based); in other words, board[i][j] = (i + 1) * (j + 1).

Initially, all the cells in the board are considered active, though some of them will eventually be deactivated through a sequence of queries - specifically, you will be given an array queries, where each query is of one of the following 3 types:

[0] - find the minimum value among all remaining active cells on the board.

[1, i] - deactivate all cells in row i;

[2, j] - deactivate all cells in column j;

Given the dimensions n, m, and the array of queries, your task is to return an array consisting of calculated values (results of the queries of the 0th type), in the order in which they were calculated.

Example

For n = 3, m = 4, and queries = [[0], [1, 2], [0], [2, 1], [0], [1, 1], [0]], the output should be solution(n, m, queries) = [1, 1, 2, 6].

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions