|
||||||||||
Rotation Lock PuzzleTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2422 Accepted Submission(s): 813 Problem Description Alice was felling into a cave. She found a strange door with a number square matrix. These numbers can be rotated around the center clockwise or counterclockwise. A fairy came and told her how to solve this puzzle lock: ¡°When the sum of main diagonal and anti-diagonal is maximum, the door is open.¡±. Here, main diagonal is the diagonal runs from the top left corner to the bottom right corner, and anti-diagonal runs from the top right to the bottom left corner. The size of square matrix is always odd. This sample is a square matrix with 5*5. The numbers with vertical shadow can be rotated around center ¡®3¡¯, the numbers with horizontal shadow is another queue. Alice found that if she rotated vertical shadow number with one step, the sum of two diagonals is maximum value of 72 (the center number is counted only once). Input Multi cases is included in the input file. The first line of each case is the size of matrix n, n is a odd number and 3<=n<=9.There are n lines followed, each line contain n integers. It is end of input when n is 0 . Output For each test case, output the maximum sum of two diagonals and minimum steps to reach this target in one line. Sample Input
Sample Output
Source | ||||||||||
|