其他分享
首页 > 其他分享> > Luogu P1387 最大正方形

Luogu P1387 最大正方形

作者:互联网

原题传送门

#include <bits/stdc++.h>
using namespace std;

int mp[105][105];
int ans[105][105];

int main()
{
	int n, m;
	cin >> n >> m;

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			cin >> mp[i][j];
		}
	}

	int final = -1;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (mp[i][j] == 1)
			{
				ans[i][j] = 1 + min(min(ans[i - 1][j - 1], ans[i - 1][j]), ans[i][j - 1]);
				final = max(final, ans[i][j]);
			}
		}
	}

	cout << final << endl;
}

标签:std,原题,int,Luogu,P1387,正方形,mp,main,105
来源: https://blog.csdn.net/qq_43033347/article/details/87888673