DatabricksOA #7
Letter "Y" on a Square Matrix
估计中等可在线判题
You are given a square matrix of odd order whose cell values are only 0, 1, or 2. Choose one digit as the digit of the Y: its upper part consists of the two diagonals running from the top-left corner to the center and from the top-right corner to the center, and below the center it is the middle column; every cell outside the Y must become one other, different digit. Find the minimum number of cells that must be changed.
Standard input/output, this site's supplementary ranges, and the examples follow this problem's description.
输入格式
The first line contains an odd n (1≤n≤99), followed by n lines, each with n values of 0, 1, or 2. The upper bound on n is a site supplement.
输出格式
Output the minimum number of cells to change.
样例 1
输入:
3
1 0 1
2 1 2
2 1 2
输出:
1
样例 2
输入:
5
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
输出:
7
样例 3
输入:
3
0 1 2
1 2 0
2 0 1
输出:
4