标签:als int icpc eof nal size ret scan char
#include<map>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
const int N=1010;
int val[N][N];
int res[N][N];
char c[N][N];
int n,m;
bool check(int mid)
{
memset(res,0,sizeof res);
for(int i =1; i<=n; i++)
for(int j=1; j<=m; j++)
//处理列
if(val[i][j]>=mid)
{
res[i][j]=res[i-1][j]+1;
//连续的列
if(res[i][j]>=mid)
return true;
}
return false;
}
int main()
{
scanf("%d %d",&n,&m);
for(int i = 1; i<=n; i++)
scanf("%s",c[i]+1);
//以i j 结尾 这一行往后有多少连续相同的字母
for(int i =1; i<=n; i++)
for(int j=1; j<=m; j++)
if(c[i][j]==c[i][j-1])
val[i][j]=val[i][j-1]+1;
else
val[i][j]=1;
int l=1,r=1001;
while(l<r)
{
int mid=(l+r+1)>>1;
if(check(mid))
l=mid;
else
r=mid-1;
}
printf("%d\n",l*l);
}
2019-2020 ACM-ICPC Latin American Regional Programming Contest L - Leverage MDT
标签:als int icpc eof nal size ret scan char
原文地址:https://www.cnblogs.com/QingyuYYYYY/p/12664987.html