Cherry and Squares Solutions
Cherry has a lattice A comprising of N lines and M segments, loaded up with lowercase English letters.
You are asked Q questions. Each question is given by four numbers x1, y1, x2, y2 which characterize the square shape, where (x1, y1) represents the directions of the upper left cell of the square shape, while (x2, y2) represents the directions of the base right cell. The response to the inquiry is the size of the most extreme square, that is found completely inside the question square shape with the end goal that :
The characters of each line ought to be in non-diminishing request.
The characters of every section ought to be in non-diminishing request.
Note: x1 speaks to the line number while y1 speaks to the section number.
Information: The primary line of the info contains two numbers N and M — the quantity of lines and the quantity of sections in the framework.
Every one of the following N lines contains a line of M lowercase English letters indicating one line of the grid.
Next line contains a number Q — the quantity of inquiries.
At that point follow Q lines with questions portrayals. Every one of them contains four numbers x1, y1, x2, y2 — directions of the up left and base right cells of the inquiry square shape.
Yield: Print Q lines. The I-th of them ought to contain the most extreme size of the square for the I-th question.
1 2 3
3 1 4
Model Case 1:
Question 1: The greatest size square that lies inside the inquiry square shape is 2. One of the such squares is:
Question 2: The greatest size square that lies inside the inquiry square shape is 1. One of the such square is:
Question 3: The greatest size square that lies inside the inquiry square shape is 2. One of the such square is:
November Challenge 2020 SOLUTION CodeChef
- Ada and Dishes SOLUTION ADADISH
- Iron Magnet and Wall SOLUTION FEMA2
- Magical Candy Store SOLUTION CNDYGAME
- Unusual Queries SOLUTION UNSQUERS
- Red-Black Boolean Expression SOLUTION RB2CNF
- Chef and the Combination Lock SOLUTION CHEFSSM
- Scalar Product Tree SOLUTION SCALSUM
- Connect on a Grid (Challenge) SOLUTION CONGRID
- Selecting Edges SOLUTION SELEDGE