Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int Maximum(int a[100]){
- int temp;
- for(int i=0;i<3;i++){
- for(int j=i+1;j<4;j++){
- if(a[i]>a[j]){
- temp=a[i];
- a[i]=a[j];
- a[j]=temp;
- }
- }
- }
- return a[3];
- }
- int main(){
- int testCase;
- cin>>testCase;
- for(int t=0;t<testCase;t++){
- int n;
- cin>>n;
- int row=2*n;
- int col=2*n;
- int mat[500][500];
- int sum=0;
- int testArray[100];
- for(int i=0;i<row;i++){
- for(int j=0;j<col;j++){
- cin>>mat[i][j];
- }
- }
- //cout<<endl;
- int n1=row-1;
- for(int i=0;i<=n1;i++){
- for(int j=0;j<=n1;j++){
- testArray[0]=mat[i][j];
- //cout<<testArray[0]<<" ";
- testArray[1]=mat[n1-i][j];
- //cout<<testArray[1]<<" ";
- testArray[2]=mat[i][n1-j];
- //cout<<testArray[2]<<" ";
- testArray[3]=mat[n1-i][n1-j];
- //cout<<testArray[3]<<" "<<endl;
- //cout<<Maximum(testArray)<<endl;
- sum=sum+Maximum(testArray);
- }
- //cout<<endl;
- }
- cout<<sum/4<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement