2019-2020 ACM-ICPC Latin American Regional Programming Contest L - Leverage MDT

Posted qingyuyyyyy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2019-2020 ACM-ICPC Latin American Regional Programming Contest L - Leverage MDT相关的知识,希望对你有一定的参考价值。

#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
",l*l);
}

以上是关于2019-2020 ACM-ICPC Latin American Regional Programming Contest L - Leverage MDT的主要内容,如果未能解决你的问题,请参考以下文章

2019-2020 ACM-ICPC Latin American Regional Programming Contest I - Improve SPAM 树形dp?

训练20191007 2017-2018 ACM-ICPC Latin American Regional Programming Contest

2017-2018 ACM-ICPC Latin American Regional Programming Contest

2017-2018 ACM-ICPC Latin American Regional Programming Contest GYM101889

2017-2018 ACM-ICPC Latin American Regional Programming Contest Solution

2020-2021 ACM-ICPC Latin American Regional Programming Contest(F. Fascinating Partitions)