#include <iostream>
void LineOf(bool** n1, bool** n2, int column, int raw, int* result) {
? ? for (int i = 0; i < column; i++) {
? ? ? ? int d = -1, n = -1;
? ? ? ? // 反向遍歷,找最后一個 true
? ? ? ? for (int j = raw - 1; j >= 0; j--) {
? ? ? ? ? ? if (n1[i][j] && d == -1) d = j;
? ? ? ? ? ? if (n2[i][j] && n == -1) n = j;
? ? ? ? ? ? if (d != -1 && n != -1) break; // 提前終止
? ? ? ? }
? ? ? ? result[i] = (d != -1 && n != -1) ? abs(d - n) : -1;
? ? }
}