• 直线和凸包(HDU3952--Fruit Ninja)


    题意:http://acm.hdu.edu.cn/showproblem.php?pid=3952

    思路:https://www.cnblogs.com/ACMERY/p/4483405.html

    判断直线切凸包就是判断一下存不存在端点在直线异侧就行了。

     1 #include<cstdio>
     2 #include<cstring>
     3 #include<cmath>
     4 #include<iostream>
     5 #include<algorithm>
     6 #include<stack>
     7 #include<queue>
     8 #include<string>
     9 #include<map>
    10 #include<set>
    11 #define maxn 11
    12 #define INF
    13 #define eps 1e-8
    14 #define zero(x) (((x)>0?(x):-(x))<eps)
    15 #define _sign(x) ((x)>eps?1:((x)<-eps?2:0))
    16 using namespace std;
    17 #define rep(i,n) for(int i=0;i<n;i++)
    18 #define rep1(i,x,y) for(int i=x;i<=y;i++)
    19 int T,m;
    20 int n[maxn];
    21 struct point
    22 {
    23     double x,y;
    24 } p[maxn][11];
    25 double xmult(point p1,point p2,point p0)
    26 {
    27     return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
    28 }
    29 int opposite(point p1,point p2,point l1,point l2)
    30 {
    31     return xmult(l1,p1,l2)*xmult(l1,p2,l2)<-eps||fabs(xmult(l1,p1,l2)*xmult(l1,p2,l2))<eps;
    32 }
    33 int main()
    34 {
    35     scanf("%d",&T);
    36     for(int cas=1; cas<=T; cas++)
    37     {
    38         scanf("%d",&m);
    39         for(int i=0; i<m; i++)
    40         {
    41             scanf("%d",&n[i]);
    42             for(int j=0; j<n[i]; j++)
    43             {
    44                 scanf("%lf %lf",&p[i][j].x,&p[i][j].y);
    45             }
    46         }
    47         int cnt=0;
    48         int maxx=-1;
    49         for(int i=0; i<m; i++)
    50             for(int j=0; j<n[i]; j++)
    51                 for(int k=0; k<m; k++)
    52                     for(int q=0; q<n[k]; q++)
    53                     {
    54                         cnt=0;
    55                         for(int w=0; w<m; w++)
    56                         {
    57                             int flag=0;
    58                             for(int u=0; u<n[w]; u++)
    59                             {
    60                                 for(int v=0; v<n[w]; v++)
    61                                 {
    62                                     if(opposite(p[w][u],p[w][v],p[i][j],p[k][q]))
    63                                     {
    64                                         cnt++;
    65                                         flag=1;
    66                                         break;
    67                                     }
    68                                 }
    69                                 if(flag)
    70                                     break;
    71                             }
    72                         }
    73                         maxx=max(maxx,cnt);
    74                     }
    75         printf("Case %d: %d
    ",cas,maxx);
    76     }
    77     return 0;
    78 }
  • 相关阅读:
    外设简述
    代C语言上机实践
    css动画效果
    css滑动门原理
    css整理
    html
    html单词
    倒计时.js
    随机方块
    求字符串出现次数和最大值
  • 原文地址:https://www.cnblogs.com/--HPY-7m/p/12340879.html
Copyright © 2020-2023  润新知