求助,wa7个点
  • 板块P1578 奶牛浴场
  • 楼主lc_lca
  • 当前回复2
  • 已保存回复2
  • 发布时间2020/5/23 10:31
  • 上次更新2023/11/7 01:59:21
查看原帖
求助,wa7个点
120340
lc_lca楼主2020/5/23 10:31
#include<iostream>
#include<algorithm>
#define ing long long
using namespace std;
int l,w;
int n;
struct node{
    int x,y;
}a[5010];
bool cmp1(node a,node b)
{
    if(a.x!=b.x) return a.x<b.x;
    return a.y>b.y;
}
bool cmp2(node a,node b)
{
    if(a.x!=b.x) return a.x>b.x;
    return a.y>b.y;
}
bool cmp3(node a,node b)
{
    return a.y>b.y;
}
signed main()
{
    cin>>l>>w;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].x>>a[i].y;
    }
    n++;
    a[n].x=0;a[n].y=0;
    n++;
    a[n].x=0;a[n].y=w;
    n++;
    a[n].x=l;a[n].y=0;
    n++;
    a[n].x=l;a[n].y=w;
    sort(a+1,a+n+1,cmp1);
    int res=0;
    for(int i=1;i<=n;i++)
    {
        int length=l-a[i].x;
        int foot=0,head=w;
        for(int j=i+1;j<=n;j++)
        {
            if(a[j].y<foot || a[j].y>head) continue;
            if(length*abs(a[j].y-a[i].y)<=res) break;
            if(a[j].y==a[i].y) break;
            if(a[j].y>a[i].y)
            {
                foot=max(foot,a[j].y);
            }
            else head=min(head,a[j].y);
            res=max(res,(a[j].x-a[i].x)*abs(foot-head));
        }
    }
    //cout<<res<<endl;
    sort(a+1,a+n+1,cmp2);
    res=0;
    for(int i=1;i<=n;i++)
    {
        int length=l-a[i].x;
        int foot=0,head=w;
        for(int j=i+1;j<=n;j++)
        {
            if(a[j].y<foot || a[j].y>head) continue;
            if(length*abs(a[j].y-a[i].y)<=res) break;
            if(a[j].y==a[i].y) break;
            if(a[j].y>a[i].y)
            {
                foot=max(foot,a[j].y);
            }
            else head=min(head,a[j].y);
            res=max(res,(a[j].x-a[i].x)*abs(foot-head));
        }
    }
    sort(a+1,a+n+1,cmp3);
    for(int i=1;i<=n-1;i++)
    {
        res=max(res,abs(a[i].y-a[i+1].y)*l);
    }
    cout<<res<<endl;
    return 0;
}

2020/5/23 10:31
加载中...