Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN PYTHON: You are given two numbers and representing the dimensions of an rectangular board. The rows of the board are numbered from to and

IN PYTHON:

image text in transcribedimage text in transcribed

You are given two numbers and representing the dimensions of an rectangular board. The rows of the board are numbered from to and the columns are numbered from to . Each cell has a value equal to the product of its row index and column index (both -based); in other words, 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 where each query is of one of the following 3 types: - find the minimum value among all remaining active cells on the board. - deactivate all cells in row - deactivate all cells in column Given the dimensions n, and the array of queries, your task is to return an array consisting of calculated values (results of the queries of the type), in the order in which they were calculated. Example For , and queries =[[0],[1,2],[0],[2,1],[0],[1,1],[0]], the output should be solution (n,m, queries )=[1,1,2,6]. Expand to see the example video. min value is 1 Expand to see the example video. - In the beginning, all cells are active, hence the minimum value among all remaining active cells is board[0] [0] = 1 . - After the second query, only the second row is inactive, so the minimum value is still - After the fourth query, the second row and the first column are inactive, so the answer is board [0] [1]=1 - 2=2; - Finally, the first and the second rows and the first column are inactive, so the answer is Input/Output - [execution time limit] 4 seconds (py3) - [input] integer n The number of rows on the board. Guaranteed constraints: - [input] integer m The number of columns on the board. Guaranteed constraints: - [input] array.array.integer queries The list of given queries. For each valid, , one of the following is true: o it then - if , then It is also guaranteed that no row or column is deactivated twice, and that at the end at least one row and at least one column are active. Guaranteed constraints: - [output] array.integer64 An array of the calculated minimum values. The lenqth of this array should be equal to the number of type queries

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

More Books

Students also viewed these Databases questions