// C is for "Chiwawa" #include #include #define IMPO "Impossible" #define N_MAX 8 #define INF 1145141919 #define CPARSE(a, b) ((a) * n + (b)) // #define AXES(a, x) int m, n; bool a[N_MAX][N_MAX]; bool b[N_MAX][N_MAX]; bool c[N_MAX][N_MAX]; void deb(){ int i, j; for(i=0;i= 0; i--) { if (*axes(where(i))) seija(where(i)); } for (i = 1; i < m; i++) { for (j = 1; j < n; j++) { if (c[i - 1][j - 1]) { b[i][j] = true; seija(CPARSE(i, j)); } else { b[i][j] = false; } } if (c[i - 1][n - 1]) { return false; } } for (j = 0; j < n; j++) { if (c[m - 1][j]) return false; } return true; } int howmany(){ int result = 0; int i, j; for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { if (b[i][j]) result++; } } return result; } int solve(){ int i, j; int ans = INF; for (i = (n - 1) * 2; i >= 0; i--) *axes(where(i)) = false; for (;;) { if (fill()) { int maybe = howmany(); if (maybe < ans) ans = maybe; } if(!incf()) break; } if (ans < INF) { printf("%d\n", ans); } else { puts(IMPO); } return! 114514; } int main(void){ int i, j; int x; scanf("%d %d", &m, &n); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { scanf("%d", &x); a[i][j] = (bool)x; } } solve(); return 0; }