POJ 1696

题目链接:http://poj.org/problem?id=1696

————————————————————————————

题目思路:

简单凸包,用的叉积擂台赛,注意当有共线点时的处理。一遍ac

————————————————————————————

源代码:

#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;
#define INF 10000000000
#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define maxn 110
const double eps = 1e-10;

typedef double T;

int n = 0;

struct Pt
{
   T x;
   T y;
   int index;
   int flag;

   Pt(){}
   Pt(T px,T py) { x = px; y = py; }

   Pt operator +(const Pt &p) { return Pt(x+p.x,y+p.y); }

   Pt operator -(const Pt &p) { return Pt(x-p.x,y-p.y); }

   int operator ==(const Pt &p)
   {
       T temp = 0;
       temp = sqrt((x - p.x)*(x - p.x)+(y-p.y)*(y-p.y));

       if(tempeps;}

int epsfun(T x)
{
    if(x<-eps || xpoint[j].x)
                          bst = j;
                    }
                    else if(cpr_three(point[cur],point[bst],point[j])<0)
                           bst = j;
                }
            }
           if(i == n-1)
              printf("%d\n",point[bst].index);
           else
              printf("%d ",point[bst].index);
           cur = bst;
           point[bst].flag = 1;
        }
    }

    return 0;
}



你可能感兴趣的:(POJ)