Prof Vanik

Dr. Vanik is well known professor of Mathematics. The class is special in which there are 2N rows and 2N columns. There are some students in his class who have complained about his teaching to Dean. So Dean has send a group of Inspectors to his class, They are about to reach anytime.

eg.

@ @ @ # # #

@ @ @ # # #

@ @ @ # # #

      • & & &
      • & & &
      • & & &

This is 2N x 2N class. N = 3

There are four corners in above class with representation (@,#,+,&)

Top-left corner is represented by ‘@’ (size = N x N)

Dr. Vanik knows that they will ask questions to students at top-left corner (N x N) because they are close to entrance of the class.Since he is LOL :slight_smile: … he will flip any row or any column any number of times and wants best possible students in top-left corner. He knows intellgence score of each student , Help him to aggregate best possible students in that corner, and print sum of intelligence score of each student.

an element a[i][j] can go to four positions arr[i][j],arr[2n-1-i][j],arr[i][2n-1-j],arr[2n-1-i][2n-1-j] one in each quadrant.
and It can be easily proved that any integer in these locations can go to any of the above location without affecting location of other elements in that quadrant.
code to maximize the quadrant:

Complexity : O(N*N)