-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1703E_Mirror_Grid.cpp
More file actions
40 lines (40 loc) · 893 Bytes
/
Copy path1703E_Mirror_Grid.cpp
File metadata and controls
40 lines (40 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
39
40
#include <bits/stdc++.h> //Problem-
using namespace std;
#define ll long long
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll t;
cin >> t;
while (t--)
{
ll n, i, j;
cin >> n;
vector<vector<char>> v(n, vector<char>(n));
ll ans = 0;
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
cin >> v[i][j];
ll m = n - 1;
for (i = 0; i < n / 2; i++)
{
for (j = i; j < (i + m); j++)
{
ll x = 0, y = n - 1 - i;
x += (v[i][j] == '1');
x += (v[j][y] == '1'); //
x += (v[y][y - (j - i)] == '1');
x += (v[y - (j - i)][i] == '1'); //
ans += min(x, 4 - x);
}
m -= 2;
}
cout << ans << endl;
}
return 0;
}