• sdut 2401 最大矩阵面积 夜


    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2401

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    using namespace std;

    const int N=1010;
    struct node
    {
        int x,y;
    }mem[N];
    bool cmp(node a,node b)
    {
        if(a.x==b.x)
        return a.y<b.y;
        return a.x<b.x;
    }
    bool cmp1(node a,node b)
    {
        if(a.y==b.y)
        return a.x<b.x;
        return a.y<b.y;
    }
    int main()
    {
        //freopen("data.txt","r",stdin);
        int T;
        int L,W,Point;
        cin>>T;
        while(T--)
        {
            cin>>L>>W;
            mem[0].x=0;mem[0].y=0;
            mem[1].x=0;mem[1].y=W;
            mem[2].x=L;mem[2].y=0;
            mem[3].x=L;mem[3].y=W;
            cin>>Point;
            for(int i=4;i<4+Point;++i)
            {
               cin>>mem[i].x>>mem[i].y;
            }
            sort(mem,mem+Point+4,cmp);
            int ans=0;
            for(int i=0;i<Point+4;++i)
            {
                for(int j=i+1,low=0,high=W,Maxl=L-mem[i].x;j<Point+4;++j)
                {
                    if(mem[j].y<=high&&mem[j].y>=low)
                    {
                        ans=max(ans,(high-low)*(mem[j].x-mem[i].x));
                        if(mem[j].y==mem[i].y)
                        break;
                        if(mem[j].y<mem[i].y)
                        low=mem[j].y;
                        else
                        high=mem[j].y;
                        if((high-low)*Maxl<=ans)
                        break;
                    }
                }
            }
            sort(mem,mem+Point+4,cmp1);
            for(int i=0;i<Point+4;++i)
            {
                for(int j=i+1,low=0,high=L,Maxl=W-mem[i].y;j<Point+4;++j)
                {
                    if(mem[j].x<=high&&mem[j].x>=low)
                    {
                        ans=max(ans,(high-low)*(mem[j].y-mem[i].y));
                        if(mem[j].x==mem[i].x)
                        break;
                        if(mem[j].x<mem[i].x)
                        low=mem[j].x;
                        else
                        high=mem[j].x;
                        if((high-low)*Maxl<=ans)
                        break;
                    }
                }
            }
            cout<<ans<<endl;
        }
        return 0;

    }

  • 相关阅读:
    VysorPro助手
    Play 2D games on Pixel running Android Nougat (N7.1.2) with Daydream View VR headset
    Play 2D games on Nexus 6P running Android N7.1.1 with Daydream View VR headset
    Native SBS for Android
    ADB和Fastboot最新版的谷歌官方下载链接
    How do I install Daydream on my phone?
    Daydream Controller手柄数据的解析
    蓝牙BLE传输性能及延迟分析
    VR(虚拟现实)开发资源汇总
    Android(Java)控制GPIO的方法及耗时分析
  • 原文地址:https://www.cnblogs.com/liulangye/p/2467012.html
Copyright © 2020-2023  润新知