#include <iostream>
#include <cstdio>
#define MAX 100
using namespace std;
int pic[MAX][MAX];
int record[MAX][MAX];// 以当前点为右下角的最大的全0正方形边长
int min(int a, int b, int c) {
if (a < b && a < c) return a;
if (b < a && b < c) return b;
return c;
}
int main(int argc, char** argv) {
int n;
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
scanf("%d", &pic[i][j]);
record[i][j] = 0;
}
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
int tmp;
scanf("%d", &tmp);
// 异或将相同区域变为0
pic[i][j] ^= tmp;
}
}
// 动态规划在矩阵中寻找最大的全0正方形区域
int max = -1;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (pic[i][j] == 0) {
if (i == 0 || j == 0) record[i][j] = 1;
else
record[i][j] = min(record[i - 1][j], record[i][j - 1], record[i - 1][j - 1]) + 1;
if (record[i][j] > max) max = record[i][j];
}
}
}
printf("%d\n", max);
return 0;
}
//15
//1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
//1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
//1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
//1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
//1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
//1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
//1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
//1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
//1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
//1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
//1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
//1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
//1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
//1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
//1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
//0 1 1 1 1 1 1 1 0 0 0 0 0 0 0
//0 1 1 1 1 1 1 1 0 0 1 1 1 1 1
//0 1 1 1 1 1 1 1 0 0 1 1 1 1 1
//0 1 1 1 1 1 1 1 0 0 1 1 1 1 1
//0 1 1 1 1 1 1 1 0 0 1 1 1 1 1
//0 1 1 1 1 1 1 1 0 0 1 1 1 1 1
//0 1 1 1 1 1 1 1 0 0 0 0 1 0 0
//0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
//0 0 0 0 0 0 0 1 1 1 1 1 0 0 1
//1 0 0 0 0 0 0 1 1 1 1 1 0 0 1
//1 1 0 0 0 0 0 1 1 1 1 1 0 0 0
//0 1 1 1 1 0 0 1 1 1 1 1 0 0 0
//0 1 1 1 1 0 0 1 1 1 1 1 0 0 0
//0 1 1 1 1 0 0 0 0 0 0 0 0 1 1
//0 1 1 1 1 0 0 0 0 0 0 0 0 1 1
2015计算机C
最新推荐文章于 2021-07-14 11:33:08 发布