Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <iostream>#include <cstdio>#include <cstdlib>#include <string.h>#include <cmath>#include <algorithm>using namespace std;typedef long long ll;int main(){int n,m;cin>>n>>m;int A[n][m];string hehe;int dp[n][m];//表示以i,j结尾的方阵满足的最大变长for(int i=0;i<n;i++){cin>>hehe;for(int j=0;j<m;j++){A[i][j]=hehe[j]-'0';dp[i][j]=1;//printf("%d\n",A[i][j]);}}int ans=1;//memset(dp,1,sizeof dp);for(int i=1;i<n;i++){for(int j=1;j<m;j++){if(!(A[i][j]!=A[i][j-1]&&A[i][j]!=A[i-1][j]))continue;int topp=dp[i-1][j];int left=dp[i][j-1];int tmp=min(topp,left);if(A[i-tmp][j-tmp]!=A[i-tmp][j-tmp+1]&&A[i-tmp][j-tmp]!=A[i-tmp+1][j-tmp])