Skip to content

Commit b4e5ede

Browse files
committed
OSSS row ascend first-column ancestors
1 parent 646572d commit b4e5ede

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

OSSS/logic.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,16 @@ function expand(blockList, shortRows, n) {
134134
for (let c = 0; c < grid[rootIndex].length; c++) {
135135
if (grid[rootIndex][c] != 0) rootRowColumns++;
136136
}
137-
const ancestorRows = getMatrixAncestorRows(matrix);
137+
const firstColumnAncestors = [matrix.length - 1];
138+
while (true) {
139+
const a = firstColumnAncestors.at(-1);
140+
const i = matrix.findLastIndex((v, i) => v[0] < matrix[a][0] && i < a);
141+
if (i < 0) break;
142+
firstColumnAncestors.push(i);
143+
}
138144
const noAscend = []; // only rows with more columns than the root row ascend
139145
for (let r = rootIndex; r < rootIndex + badPartHeight; r++) {
140-
if (ancestorRows.includes(r)) continue; // direct ancestors still should ascend
146+
if (firstColumnAncestors.includes(r)) continue; // direct/indirect ancestors still should ascend
141147
let columns = 0;
142148
for (let c = 0; c < grid[r].length; c++) {
143149
if (grid[r][c] != 0) columns++;

0 commit comments

Comments
 (0)