此题DP即可。 设f[i][j]表示以(i,j)为右下角的最大正方形边长 if (i,j)被毁了——>f[i][j]=0(没有啦) else f[i][j]=min(f[i-1][j],f[i][j-1],f[i-1][j-1])+1 答案统计即可。 #include<cstdio> #include<algorithm> using namespace std; int n,f[251][251],b[251][251],c[251]; char s[251]; int mai