hdu 4846 Big Barndp

Posted mfcheer

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hdu 4846 Big Barndp相关的知识,希望对你有一定的参考价值。

http://acm.hdu.edu.cn/showproblem.php?pid=4846

求矩阵中最大的仓库正方形

#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;

int n, t;
int a[1010][1010];
int b[1010][1010];

int main()

    while (scanf("%d %d", &n, &t) != EOF)
    
        for (int i = 0;i <= n;i++)
            for (int j = 0;j <= n;j++)
                a[i][j] = 1;

        int u, v;
        //memset(b, 0, sizeof(b));
        while (t--)
        
            scanf("%d%d", &u, &v);
            a[u][v] = 0;
        
        for (int i = 1;i <= n;i++)
        
            b[i][1] = a[i][1];
            b[1][i] = a[1][i];
        
        for(int i=2;i<=n;i++)
            for (int j = 2;j <= n;j++)
            
                if (a[i][j] == 1)
                    b[i][j] = min(b[i - 1][j - 1], min(b[i - 1][j], b[i][j - 1])) + 1;
                else
                    b[i][j] = 0;
            
        int ans = 0;
        for (int i = 1;i <= n;i++)
            for (int j = 1;j <= n;j++)
            
                ans = max(ans, b[i][j]);
            
        printf("%d\\n", ans);
    
    return 0;

以上是关于hdu 4846 Big Barndp的主要内容,如果未能解决你的问题,请参考以下文章

01背包HDU 1171 Big Event in HDU

HDU-1171 Big Event in HDU (多重背包)

HDU 1171 Big Event in HDU(多重背包)

Hdu 1171Big Event in HDU

HDU 1171 Big Event in HDU(01背包)

HDU1171--Big Event in HDU(多重背包)