-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1-5.cpp
More file actions
31 lines (31 loc) · 691 Bytes
/
1-5.cpp
File metadata and controls
31 lines (31 loc) · 691 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
#include<bits/stdc++.h>
using namespace std;
int a[105][105];
int main()
{
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
{
char x;
cin >> x;
a[i][j] = x - '0';
}
int ans = 0;
for (int i = 1; i <= (n + 1) / 2; i++)
{
for (int j = 1; j <= n / 2; j++)
{
int x = a[i][j] + a[j][n - i + 1] + a[n - i + 1][n - j + 1] + a[n - j + 1][i];
ans += min(4 - x, x);
}
}
cout << ans << endl;
}
return 0;
}