Advertisement

UVa 12265 出售土地(Selling Land)

阅读量:

题意:针对每一个网格单元,确定以该单元作为右下顶点的矩形中周长最大的一个。

分析:
逐行进行处理,同时保持一个单调递增的栈结构。
对于参考了紫书的读者而言,实际上,若不依赖书中的解析,自行思考反而能够更快地理解问题。

代码;

复制代码
    #include<bits/stdc++.h>
    #define LL long long
    #define ms(s) memset(s, 0, sizeof(s))
    using namespace std;
    const int maxn = 1e3 + 10;
    int n, m;
    char pic[maxn][maxn];
    int h[maxn][maxn];
    int ans[maxn * maxn];
    
    struct Node {
    int c, h;
    Node(int c, int h):c(c), h(h){}
    Node(){}
    };
    
    int main() {
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.ti

全部评论 (0)

还没有任何评论哟~