This problem says we need to find 4th side length of the quadrilateral given 3 lengths. There are various approaches to solve this problem. WHat I thought was that align one line parallel to OY axis and aling one line parallel to x axis and in the middle align the other line. So we get a structure something like this.
| D | | | C | | A |_______| B
Now I got 4 coordinates with three lines so 4th line is obviously. CD if AB=a , BC =b , AD =c , and assume A to be origin. Coordinate of C={a,b} , D={ 0,c}. Thus length of CD = ceil(sqrt((a-0)*(a-0)+(b-c)*(b-c))). By euclids formula. Why ceil? because to make float to integer as our quadrilateral can have sides which are aligned at angle to origin thus ceil works fine here.
In this problem we were required to make all rows and columns of the matrix palindromic. ROws=n , Cols=m For a sequence of length n to be a palindrome the element at index i must be equal to n-1-i th element index. Consider that for making ith row palindromic. element mat[i][j]=mat[m-1-j].----(1) Where j is an index among m columns.
Simialrly for making jth column palinfromic. mat[i][j]=mat[n-1-i][j] ----(2).
Equation 1 and 2 says that.
mat[i][j]=mat[i][m-1-j]=mat[n-1-i][j]=mat[n-1-i][m-1-j].
So all we were required is to make these 4 values equal to any one of them. So I brute forces over all rows from 0 to (n-1)/2 and all columns. from 0 to(m-1)/2. and find those 4 values lets say these 4 values are x,y,w,z. try making all of them equal to x or y or w or z. And take the minimum operations needed.. to make all of them equal.