• The E-pang Palace(暴力几何)


    //暴力的几何题,问,n个点可以组成的矩形,不相交,可包含的情况下,最大的面积,还有就是边一定与 x y 轴平行,所以比较简单了

    //暴力遍历对角线,搜出所有可能的矩形,然后二重循环所有矩形,判断一下,输出最大即可

     1 #include <iostream>
     2 #include <stdio.h>
     3 #include <string.h>
     4 #include <math.h>
     5 #include <stdlib.h>
     6 using namespace std;
     7 #define MX 35
     8 struct Mat
     9 {
    10     int a,b,c,d;
    11     int area;
    12 }mat[5000];
    13 
    14 int n;
    15 int x[MX];
    16 int y[MX];
    17 int G[205][205];
    18 
    19 int check(int u,int v)
    20 {
    21     int xxx = min(min(x[mat[u].a],x[mat[u].b]),min(x[mat[u].c],x[mat[u].d]));
    22     int xxy = min(min(y[mat[u].a],y[mat[u].b]),min(y[mat[u].c],y[mat[u].d]));
    23     int ddx = max(max(x[mat[u].a],x[mat[u].b]),max(x[mat[u].c],x[mat[u].d]));
    24     int ddy = max(max(y[mat[u].a],y[mat[u].b]),max(y[mat[u].c],y[mat[u].d]));
    25 
    26     int xx = min(min(x[mat[v].a],x[mat[v].b]),min(x[mat[v].c],x[mat[v].d]));
    27     int xy = min(min(y[mat[v].a],y[mat[v].b]),min(y[mat[v].c],y[mat[v].d]));
    28     int dx = max(max(x[mat[v].a],x[mat[v].b]),max(x[mat[v].c],x[mat[v].d]));
    29     int dy = max(max(y[mat[v].a],y[mat[v].b]),max(y[mat[v].c],y[mat[v].d]));
    30 
    31 
    32     if (xxx>dx||xxy>dy||ddx<xx||ddy<xy)//在 右上左下
    33         return mat[v].area+mat[u].area;
    34 
    35     if (xxx>xx&&ddx<dx&&xxy>xy&&ddy<dy)//包含
    36         return max(mat[v].area,mat[u].area);
    37     if (xxx<xx&&ddx>dx&&xxy<xy&&ddy>dy)
    38         return max(mat[v].area,mat[u].area);
    39 
    40     return 0;
    41 }
    42 
    43 int main()
    44 {
    45     while (scanf("%d",&n)&&n)
    46     {
    47         memset(G,-1,sizeof(G));
    48         for (int i=0;i<n;i++)
    49         {
    50             scanf("%d%d",&x[i],&y[i]);
    51             G[x[i]][y[i]]=i;
    52         }
    53         int m=0;
    54         for (int i=0;i<n;i++)
    55         {
    56             for (int j=i+1;j<n;j++)
    57             {
    58                 if (x[i]==x[j]||y[i]==y[j]) continue;
    59                 int fir,sec;
    60                 if (G[x[i]][y[j]]!=-1) fir=G[x[i]][y[j]];
    61                 else continue;
    62                 if (G[x[j]][y[i]]!=-1) sec=G[x[j]][y[i]];
    63                 else continue;
    64 
    65                 int lon=abs(x[i]-x[j]);
    66                 int kua=abs(y[i]-y[j]);
    67                 mat[m++]=(Mat){fir,sec,i,j,lon*kua};
    68             }
    69         }
    70         int ans = 0;
    71         for (int i=0;i<m;i++)
    72         {
    73             for (int j=i+1;j<m;j++)
    74             {
    75                 ans = max(ans,check(i,j));
    76             }
    77         }
    78         if (ans!=0)
    79             printf("%d
    ",ans);
    80         else
    81             printf("imp
    ");
    82     }
    83     return 0;
    84 }
    View Code
  • 相关阅读:
    Windows 下安装 Python + Django
    asp.net core 一个中小型项目实战的起手式——Swagger配置
    asp.net core 一个中小型项目实战的起手式——项目搭建与仓储模式下的持久层创建(1)
    c#一些常用知识点
    ADO.NET中的5个主要对象
    JavaScript的闭包特性如何给循环中的对象添加事件(一)
    在什么情况下会用到虚方法?它与接口有什么不同?
    一般处理程序Session
    什么是code-Behind技术?
    什么是事务?
  • 原文地址:https://www.cnblogs.com/haoabcd2010/p/7218736.html
Copyright © 2020-2023  润新知