KoddiOA #3
Protein Matrix Y-Pattern Transformation
简单可在线判题
考点(AI 标注)哈希计数模拟/实现
Given an n×n matrix of odd order whose elements can only be 0, 1, or 2. One operation changes a cell to one of the other values. Let m=n//2 and use 0-based coordinates; the target shape is the union of the following coordinates: (t,t) and (t,n−1−t) for 0≤t≤m, and (t,m) for m≤t<n. That is, two upper half-diagonals meet at the center, which then extends vertically down to the bottom edge. All cells inside the shape must become a single value a, and all cells outside the shape must become a single different value b, with a,b∈{0,1,2} and a≠b. Find the minimum number of cells to change. The center counts as only one cell. The Y shape of Koddi's original protein matrix is defined by the explicit coordinates above.
输入格式
The first line contains an odd n, followed by n lines of n integers each. n is 3,5,7,…,99, and values are 0..2. Koddi itself did not preserve the range of n; the same problem at Databricks019 guarantees odd n, fastprep gives 5..99, and the shared original example also includes 3; this site uses the explicit union and does not add n=1.
输出格式
Output the minimum number of cells to change as an integer. The shape and the background must use different values.
样例 1
输入:
3
1 0 2
1 2 0
0 2 0
输出:
2
样例 2
输入:
5
2 0 0 0 2
1 2 1 2 0
0 1 2 1 0
0 0 2 1 1
1 1 2 1 1
输出:
8
样例 3
输入:
3
0 0 0
0 0 0
0 0 0
输出:
4
样例说明
Original Koddi Coordinates, Ranges from the Same Problem, and Summary-Page Corrections
In the fixed commit e66f809f4c953bce129f68491726176615db6afc, OA LIST/Koddi_OA/004_image.txt defines the Y shape of the protein matrix: from the top-left and top-right along the diagonals to the center, then vertically from the center to the bottom. 005 confirms the coordinates by highlighting each cell; 006/007 give complete 3×3 and 5×5 inputs with outputs 2 and 8 respectively; 008 shows the 5×5 transformation again. The shape is one color, the background is one color, and the two colors differ, giving 6 color assignments in total.
The cross-company evidence for the same problem: the complete 3×3 and 5×5 inputs of Koddi006 and OA LIST/Databricks_OA/021_image.txt match, as do both outputs 2/8, the two sets of changed positions, the complete target matrices, and the explanation of changing 8 zeros to 1; the highlighted positions of Koddi005 and Databricks020 match. Only the protein narrative and the variable names were changed; the match is not guessed from the title.
The ranges are adopted according to the evidence: Databricks019 states explicitly that n is odd; the same problem in fastprep/Databricks/databricks-write-l-matrix.md constrains 5≤n≤99 with elements 0..2, but the original example shared by all sources has n=3. The complete envelope is therefore the union of {3} and the odd numbers 5..99, i.e., the odd numbers 3..99. n=1 is not added; this site does not claim that Koddi or DatabricksOCR itself gives the upper bound 99. fastprep's second example is missing a row, but Koddi006/007 already have the complete 5×5, so no row needs to be guessed.
The Koddi summary page's cross matrix [[0,1,0],[1,1,1],[0,1,0]] claims an answer of 1, but enumerating the six final states gives a minimum of 4: the Y region has 2 each of 0/1, and the background has 3 ones and 2 zeros; making Y 0 and the background 1 changes 4 cells and reaches the lower bound. The summary page's "4n−2 Y cells" is also wrong; the correct count is (3n−1)/2. This site keeps the two original OCR examples 2/8 and does not reuse the wrong summary example.