__Cow__ @ 2024-09-06 22:28:37
rt,没想做优化,就单打暴力,但是交上去只有第一个点输出不是0
,剩下都是0
,自己在本地测了其他帖的数据也没问题,求调
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <fstream>
using namespace std;
char a[1000][1000],n,m,ans;
bool count(int _a,int _b,int _c,int _d){
int x=0,y=0;
for (int i=_a;i<=_c;i++){
for (int j=_b;j<=_d;j++){
if (a[i][j] == '1') x+=1;
else y+=1;
}
}
//cout<<x<<" "<<y<<endl;
if (x==y) return true;
return false;
}
int main(){
scanf ("%d %d", &n, &m);
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++) cin>>a[i][j];
}
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++){
for (int k=i;k<=n;k++){
for (int _i = j;_i<=m;_i++){
//cout<<i<<" "<<j<<" "<<k<<" "<<_i<<endl;
if (count(i,j,k,_i)){
ans = (k-i+1)*(_i-j+1)>ans?(k-i+1)*(_i-j+1):ans;
}
}
}
}
}
printf ("%d\n",ans);
return 0;
}
by __Cow__ @ 2024-09-06 22:34:31
太久没有写题改类型忘分类了,此贴结。。