Samsung Competency Test 25 Aug 19
There is a large plot with various sinkholes present. Since one sinkhole can combine with another sinkhole, it is required to get at most one sinkhole while occupying the plot. You have to find the maximum square-area formed with at most one sinkhole present. If there are two plots with the same area then print the one with lesser sinkhole present otherwise if the sinkholes are also same then print anyone. For each case, you have to print the bottom leftmost coordinate and top rightmost point. Please keep in mind that the plot starts with (1, 1).
Time limit= 1sec and Memory limit– 256Mb
Input: First line will give the number of test cases. For each test case, we will be given the size of the plot matrix N x M (where 1<=N, M<=1000). Next line will give the number of sinkholes present in the matrix K (1<=K<=N+M). Next, K-lines will give the coordinates of the sinkholes.
Output: For each test case, you have to print the number of the test case and the coordinates of the resultant square. i.e. #i xb yb xt yt (ith test case, xb=bottomost left x-coordinate, yb=bottomost left y-coordinate, xt= topmost right x-coordinate, yt= topmost right y-coordinate)
Matrix Formed will look something like this-
0 0 0 0 0 1
0 0 0 0 0 0
0 0 0 1 0 0
0 0 1 0 0 0
0 0 0 0 0 0
1 0 0 0 0 0
#1 1 4 3 6
Verdict: I solved using brute-force with O(n^4) and got TLE. So was not selected. I am not sure but any approach with O(n^3) should work !!
Please Login to comment...