• <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 閱讀(843) 評論(0)  編輯 收藏 引用 所屬分類: Felicia 的標程 、計算幾何
             
            性做久久久久久久| 久久成人国产精品免费软件| 人妻丰满AV无码久久不卡| 久久综合亚洲鲁鲁五月天| 人妻无码αv中文字幕久久琪琪布| 亚洲日本va午夜中文字幕久久 | 狠狠色丁香婷婷综合久久来 | 国产精品久久久久天天影视| 久久久久久综合一区中文字幕| 97精品国产97久久久久久免费| 精品无码久久久久久国产| 四虎国产精品成人免费久久| 日韩精品久久久久久久电影蜜臀| 国产精品久久久久影院色| 欧美麻豆久久久久久中文| www久久久天天com| 久久大香萑太香蕉av| 香蕉久久一区二区不卡无毒影院| 性做久久久久久免费观看| 久久国产精品国产自线拍免费| 伊人久久五月天| 国产精品成人99久久久久 | 四虎久久影院| 国产精品美女久久久久AV福利| 久久天天躁狠狠躁夜夜avapp| 精品99久久aaa一级毛片| 久久精品国产亚洲av麻豆色欲| 亚洲国产综合久久天堂| 国产农村妇女毛片精品久久| 久久99精品国产自在现线小黄鸭| 欧美亚洲国产精品久久高清| 国产高清国内精品福利99久久| 婷婷综合久久中文字幕蜜桃三电影| 久久亚洲国产精品123区| 91精品免费久久久久久久久| 国产精品久久国产精麻豆99网站| 伊人久久无码中文字幕| 亚洲国产天堂久久久久久| 久久久精品国产亚洲成人满18免费网站| 久久97精品久久久久久久不卡| 国产成人精品久久免费动漫|