zoukankan      html  css  js  c++  java
  • P1387 最大正方形

    中文题

    想法:

    定义 dp[i][j] 代表以(i,j) 为右下角的最大正方形的边长

     图片来源:https://www.luogu.com.cn/blog/Panthera/solution-p1387

    #include <algorithm>
    #include <string>
    #include <string.h>
    #include <vector>
    #include <map>
    #include <stack>
    #include <set>
    #include <queue>
    #include <math.h>
    #include <cstdio>
    #include <iomanip>
    #include <time.h>
    #include <bitset>
    #include <cmath>
    #include <sstream>
    #include <iostream>
    #include <cstring>
    
    #define LL long long
    #define ls nod<<1
    #define rs (nod<<1)+1
    #define pii pair<int,int>
    #define mp make_pair
    #define pb push_back
    #define INF 0x3f3f3f3f
    
    const double eps = 1e-10;
    const int maxn = 100 + 10;
    const LL mod = 1e9 + 7;
    
    int sgn(double a){return a < -eps ? -1 : a < eps ? 0 : 1;}
    using namespace std;
    
    int f[maxn][maxn];
    int a[maxn][maxn];
    
    int main() {
        ios::sync_with_stdio(false);
        int n,m;
        cin >> n >> m;
        int ans = 0;
        for (int i = 1;i <= n;i++) {
            for (int j = 1;j <= m;j++) {
                cin >> a[i][j];
                if (a[i][j]) {
                    f[i][j] = min(f[i-1][j-1],min(f[i-1][j],f[i][j-1])) + 1;
                    ans = max(ans,f[i][j]);
                }
            }
        }
        cout << ans << endl;
        return 0;
    }

    当然这题 单调队列也可以做

  • 相关阅读:
    zepto.js常用操作
    使用require.js
    iscroll.js文档
    EasyUI Resizable 可调整尺寸
    EasyUI Droppable 可放置
    EasyUI Draggable 可拖动
    EasyUI Parser 解析器
    EasyUI Easyloader 加载器
    Jquery EasyUI插件
    从MySQL随机选取数据
  • 原文地址:https://www.cnblogs.com/-Ackerman/p/12489451.html
Copyright © 2011-2022 走看看