• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            /*************************************************************************
            Author: WHU_GCC
            Created Time: 2007-8-13 13:59:37
            File Name: convex_hull.cpp
            Description: 
            ***********************************************************************
            */

            #include 
            <iostream>
            using namespace std;

            #define out(x) (cout << #x << ": " << x << endl)
            typedef 
            long long int64;
            const int maxint = 0x7FFFFFFF;
            const int64 maxint64 = 0x7FFFFFFFFFFFFFFFLL;
            template 
            <class T> void show(T a, int n) for (int i = 0; i < n; ++i) cout << a[i] << ' '; cout << endl; }
            template 
            <class T> void show(T a, int r, int l) for (int i = 0; i < r; ++i) show(a[i], l); cout << endl; }

            const int maxn = 200;

            typedef 
            struct point_t
            {
                
            int x, y;
            }
            ;

            typedef 
            struct polygon_t
            {
                
            int n;
                point_t p[maxn];
            }
            ;

            int operator <(const point_t &a, const point_t &b)
            {
                
            return a.y < b.y || a.y == b.y && a.x < b.x;
            }


            point_t 
            operator -(const point_t &a, const point_t &b)
            {
                point_t ret;
                ret.x 
            = a.x - b.x;
                ret.y 
            = a.y - b.y;
                
            return ret;
            }


            double dist(const point_t &a, const point_t &b)
            {
                
            return sqrt(double((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)));
            }


            int cross(const point_t &a, const point_t &b)
            {
                
            return a.x * b.y - a.y * b.x;
            }


            int turn_left(const point_t &a, const point_t &b, const point_t &c)
            {
                
            return cross(b - a, c - b) > 0;
            }


            class point_set_c
            {
            public:
                
            void init(int _n, point_t _p[]);
                polygon_t convex_hull();
            private:
                
            int n;
                point_t p[maxn];
            }
            ;

            void point_set_c::init(int _n, point_t _p[maxn])
            {
                n 
            = _n;
                
            for (int i = 0; i < n; i++)
                    p[i] 
            = _p[i];
            }


            polygon_t point_set_c::convex_hull()
            {
                
            int stack[maxn];
                
            int top = 1;
                stack[
            0= 0;

                sort(p, p 
            + n);

                
            for (int i = 1; i < n;)
                
            {
                    
            if (top == 1 || turn_left(p[stack[top - 2]], p[stack[top - 1]], p[i]))
                        stack[top
            ++= i++;
                    
            else top--;
                }

                
            int t_top = top;
                
            for (int i = n - 2; i >= 0;)
                
            {
                    
            if (top == t_top || turn_left(p[stack[top - 2]], p[stack[top - 1]], p[i]))
                        stack[top
            ++= i--;
                    
            else top--;
                }

                
                polygon_t ret;
                ret.n 
            = 0;
                
            for (int i = 0; i < top - 1; i++)
                    ret.p[ret.n
            ++= p[stack[i]];
                
            return ret;
            }
            posted on 2007-08-13 14:49 Felicia 閱讀(853) 評論(0)  編輯 收藏 引用 所屬分類: Felicia 的標程計算幾何
             
            免费精品国产日韩热久久| 老男人久久青草av高清| 国产精品嫩草影院久久| 国内精品久久久久久中文字幕| 久久国产热这里只有精品| 伊人久久成人成综合网222| 97久久国产露脸精品国产 | 色诱久久久久综合网ywww| 久久大香香蕉国产| 美女久久久久久| 久久99精品久久久久久久不卡| 国产成人精品久久亚洲高清不卡 | 亚洲?V乱码久久精品蜜桃| 国内精品伊人久久久久av一坑 | 久久涩综合| 久久久青草青青亚洲国产免观| 人妻少妇精品久久| Xx性欧美肥妇精品久久久久久| 久久久久久久精品妇女99| 久久久久久国产精品免费免费| 久久人人爽人人爽人人AV| 思思久久99热只有频精品66| 国产免费久久精品99久久| 久久精品国产亚洲av日韩| 国产精品中文久久久久久久| 久久久久久青草大香综合精品| 国产精品美女久久久久久2018| 久久精品国产亚洲AV影院| 欧美久久久久久精选9999| 日韩精品国产自在久久现线拍| 久久天天躁狠狠躁夜夜躁2O2O| 久久国产免费直播| 精产国品久久一二三产区区别| 亚洲国产香蕉人人爽成AV片久久| 欧美一区二区精品久久| 国产精品青草久久久久婷婷| 国产成人无码久久久精品一| 久久er99热精品一区二区| 国产精品久久久亚洲| 国产亚洲综合久久系列| 久久99中文字幕久久|