Figurel: A solution for the sample input. The rectangular pieces cover the cake entirely, so there are no leftovers. This solution is described in the sample output. Input format: The first line contains p, q, and n, where pxq are the dimensions of the cake and n is the number of roses. Then n lines follow, the i-th line contains the coordinates of the i-th rose, where the first coordinate is between 1 and p and the second coordinate is between 1 and q. Output format: The output contains n+1 lines. The first n lines contain four numbers each: the j-th line contains aj, bj, cj, dj, where 1sajscjsp and 1sbjsdjsq and (aj,bj) and (cj,dj) correspond to the grid squares at the opposite corners of the rectangular piece for the j-th person. The rectangular pieces have to be non-overlapping. The last line contains a single number, the area of the leftovers. The area of the leftovers should be the smallest possible. Code constraints: 0< p, q, n <=10000.
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
Please do not give solution in image format thanku
Figurel: A solution for the sample input. The rectangular pieces cover the cake entirely, so there are no leftovers. This solution is described in the
sample output.
Input format:
The first line contains p, q, and n, where pxq are the dimensions of the cake and n is the number of roses. Then n lines follow, the i-th line contains the
coordinates of the i-th rose, where the first coordinate is between 1 and p and the second coordinate is between 1 and q.
Output format:
The output contains n+1 lines. The first n lines contain four numbers each: the j-th line contains aj, bj, cj, dj, where 1sajscjsp and 1sbjsdjsq and (aj,bj)
and (cj,dj) correspond to the grid squares at the opposite corners of the rectangular piece for the j-th person. The rectangular pieces have to be
non-overlapping. The last line contains a single number, the area of the leftovers. The area of the leftovers should be the smallest possible.
Code constraints:
0< p, q, n <=10000.
Step by step
Solved in 4 steps with 1 images