样例过不了,求条QwQ
查看原帖
样例过不了,求条QwQ
1125106
11514zbs楼主2024/7/12 07:22
#include <cstdio>
int n, m, r, a[2005][2005], mc, x2, y2;
bool flag;

int min(int a, int b)
{
    return (a < b) ? b : a;
}

int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
	{
        for (int j = 0; j < m; j++)
		{
            scanf("%d", &a[i][j]);
        }
    }
    for (int x1 = 0; x1 < n; x1++)
	{
        for (int y1 = 0; y1 < m; y1++)
		{
            for (int c = 1; c <= min(n - x1, m - y1); c++)
            {
                x2 = x1 + c - 1;
                y2 = y1 + c - 1;
                for (int i = x1; i <= x2; i++)
                {
                    for (int j = y1; j <= y2; j++)
                    {
                        if (a[i][j] == 0)
                        {
                            flag = 0;
                            break;
                        }
                        else
                        {
                            flag = 1;
                        }
                    }
                    if (!flag)
                    {
                        break;
                    }
                    else if (c > mc)
                    {
                        mc = c;
                    }
                }
            }
        }
    }
    printf("%d", mc);
    return 0;
}

2024/7/12 07:22
加载中...