subject

Consider a prison gate having N horizontal rods and M vertical rods. You are also provided with two vectors hor and ver containing the
row number of missing horizontal rods and vertical rods respectively.
Return the area of biggest hole in the prison gate.
1 <= N, M <= 1000000
1 <= hor[i] <= N
1 <= ver[i] <= M
All the elements of a vector are distinct
O(N + M)
SKIPPING... O(AlogA + BlogB) where A = hor. size() and B = ver. size()
*/
#include
using namespace std;
long int prison(int n, int m, vector hor, vector ver) {
vector xs(n + 1), ys(m + 1);
for (int h : hor) xs[h] = true;
for (int v : ver) ys[v] = true;
int xm = 0, ym = 0;
for (int i = 1, j = 0; i <= n; i++) { if (not xs[i]) j = 0;
else xm = max(xm, ++j);
}
for (int i = 1, j = 0; i <= m; i++) {
if (not ys[i]) j = 0;
else ym = max(ym, ++j);
}
return (long int)(xm + 1) * (ym + 1);
}
int main() {
cout << prison(10, 10, {}, {});
return 0;
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 17:40
Gabe wants to move text from one document to another document. he should copy the text, paste the text, and open the new document highlight the text, select the cut command, move to the new document, make sure the cursor is in the correct location, and select the paste command select the save as command, navigate to the new document, and click save highlight the text, open the new document, and press ctrl and v
Answers: 1
question
Computers and Technology, 23.06.2019 19:00
Write a program that displays the following menu: geometry calculator 1. calculate the area of a circle 2. calculate the area of a rectangle 3. calculate the area of a triangle 4. quit enter your choice (1-4): if the user enters 1, the program should ask for the radius of the circle and then display its area. use the following formula: area = ď€(the square of r) use 3.14159 for ď€ and the radius of the circle for r. if the user enters 2, the program should ask for the length and width of the rectangle and then display the rectangle’s area. use the following formula: area = length * width if the user enters 3, the program should ask for the length of the triangle’s base and its height, and then display its area. use the following formula: area = base * height * .5 if the user enters 4, the program should end. input validation: display an error message if the user enters a number outside the range of 1 through 4 when selecting an item from the menu. do not accept negative values for the circle’s radius, the rectangle’s length or width, or the triangle’s base or height. note: if the user enters an improper menu choice (1-4), the program prints "the valid choices are 1 through 4. run the program again and select one of those." if the user enters a negative radius, the program prints "the radius can not be less than zero." if the user enters a negative value for height or base, the program prints "only enter positive values for base and height."
Answers: 1
question
Computers and Technology, 23.06.2019 21:20
In microsoft word, when you highlight existing text you want to replace, you're in              a.  advanced mode.    b.  automatic mode.    c.  basic mode.    d.  typeover mode
Answers: 1
question
Computers and Technology, 24.06.2019 08:30
Formatting rows and columns is similar to cell formatting. in an openoffice calc spreadsheet, you can format data entered into rows and columns with the of the rows and columns options. you can insert rows and columns into, or delete rows and columns from, a spreadsheet. use the insert or delete rows and columns option on the insert tab. alternatively, select the row or column where you want new rows or columns to appear, right-click, and select insert only row or only column options. you can hide or show rows and columns in a spreadsheet. use the hide or show option on the format tab. for example, to hide a row, first select the row, then choose the insert tab, then select the row option, and then select hide. alternatively, you can select the row or columns, right-click, and select the hide or show option. you can adjust the height of rows and width of columns. select row and then select the height option on the format tab. similarly, select column, then select the width option on the format tab. alternatively, you can hold the mouse on the row and column divider, and drag the double arrow to the position. you can also use the autofit option on the table tab to resize rows and columns.
Answers: 1
You know the right answer?
Consider a prison gate having N horizontal rods and M vertical rods. You are also provided with two...
Questions
question
Mathematics, 06.05.2021 08:30
question
Mathematics, 06.05.2021 08:30
question
Mathematics, 06.05.2021 08:30
question
Mathematics, 06.05.2021 08:30
question
Business, 06.05.2021 08:30
question
Mathematics, 06.05.2021 08:30
question
Mathematics, 06.05.2021 08:30
Questions on the website: 13722367