forked from chencorey/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlipping the Matrix.cpp
More file actions
38 lines (35 loc) · 893 Bytes
/
Flipping the Matrix.cpp
File metadata and controls
38 lines (35 loc) · 893 Bytes
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
34
35
36
37
38
// https://www.hackerrank.com/contests/world-codesprint-6/challenges/flipping-the-matrix
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int cases;
cin>>cases;
for(int i =0; i<cases; i++)
{
long long mat[256][256];
int n;
cin>>n;
for(int j = 0; j<2*n; j++)
{
for(int k = 0; k<2*n; k++)
{
cin>>mat[j][k];
}
}
long long total = 0;
for(int j = 0; j<n; j++)
{
for(int k = 0; k<n; k++)
{
total+=max(max(mat[j][k], mat[2*n-1-j][k]),max(mat[j][2*n-1-k], mat[2*n-1-j][2*n-1-k]));
}
}
cout<<total<<endl;
}
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
return 0;
}