-
-
Notifications
You must be signed in to change notification settings - Fork 109
/
FlippingtheMatrix.java
33 lines (31 loc) · 939 Bytes
/
FlippingtheMatrix.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t--!=0){
int n=sc.nextInt();
int a[][]=new int[2*n][2*n];
int b[][]=new int[2*n][2*n];
for(int i=0;i<2*n;i++){
for(int j=0;j<2*n;j++){
a[i][j]=sc.nextInt();
b[i][j]=a[i][j];
}
}
int sum=0,t1;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
t1=Math.max(Math.max(a[i][j],a[2*n-1-i][j]),Math.max(a[i][2*n-1-j],a[2*n-1-i][2*n-1-j]));
//System.out.println(t1);
sum+=t1;
}
}
System.out.println(sum);
}
}
}