include stdio define min define max int 1500 1500 int main int freopen

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include<stdio.h>
#define min(A,B) ((A) < (B) ? (A) : (B))
#define max(A,B) ((A) > (B) ? (A) : (B))
int a[1500][1500];
int main()
{
int n;
freopen("INPUT.TXT", "r", stdin);
freopen("OUTPUT.TXT", "w", stdout);
scanf("%d\n",&n);
int i,j,result = 0;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
char k;
scanf("%c", &k);
if(k == '1')
{
int m = min(a[i][j-1],a[i-1][j]);
m = min(m,a[i-1][j-1]);
a[i][j] = m + 1;
result = max(result, a[i][j]);
}
}
scanf("\n");
}
printf("%d\n",result*result);
fclose(stdin);
fclose(stdout);
return 0;
}