题目:黑白方块
得分:65
用时:62ms
内存:676KB
状态:#1,#2,#3,#6,#7,#9,#10,#11,#12,#13,#16,#18,#19AC;#4,#5,#8,#14,#15,#17,#20WA
代码:
#include<bits/stdc++.h>
using namespace std;
int g[17][17];
bool same(int sx,int sy,int ex,int ey)
{
int w=0,b=0;
for(int i=sx;i<ex;i++)
{
for(int j=sy;j<ey;j++)
{
if(g[i][j]==0) b++;
else w++;
}
}
if(b==w) return true;
return false;
}
int main()
{
int n,m;
string s;
cin>>n>>m;
for(int i=0;i<n;i++)
{
cin>>s;
for(int j=0;j<m;j++) g[i][j]=int(s[j]-48);
}
for(int i=n;i>0;i--)
{
for(int j=m;j>0;j--)
{
if((i*j)%2==1) continue;
for(int k=0;k<=n-i;k++)
{
for(int l=0;l<=m-j;l++)
{
if(same(k,l,k+i,l+j))
{
cout<<i*j;
return 0;
}
}
}
}
}
cout<<0;
return 0;
}