• <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 閱讀(844) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Felicia 的標(biāo)程計(jì)算幾何
             
            久久A级毛片免费观看| 亚洲精品高清一二区久久| 久久亚洲综合色一区二区三区| 久久国产精品波多野结衣AV| 亚洲&#228;v永久无码精品天堂久久| 亚洲精品美女久久久久99小说 | 精品国产乱码久久久久软件| 久久精品国产亚洲av麻豆色欲| 久久久久无码国产精品不卡| 中文字幕人妻色偷偷久久| 久久精品18| 久久亚洲精品中文字幕三区| 久久国产色av免费看| 久久99精品久久久久久野外| 久久久久久久久无码精品亚洲日韩 | 色妞色综合久久夜夜| 91精品国产91久久久久久| 欧美喷潮久久久XXXXx| 午夜视频久久久久一区| 日本道色综合久久影院| 精品无码久久久久久尤物| 无码国内精品久久综合88 | 久久婷婷五月综合色高清| 少妇被又大又粗又爽毛片久久黑人 | 久久久99精品一区二区| 久久精品国产亚洲综合色| av无码久久久久久不卡网站| 亚洲国产精品一区二区久久hs| 最新久久免费视频| 欧美激情精品久久久久久久| 久久国产成人| 久久精品国产一区二区电影| 亚洲伊人久久大香线蕉苏妲己| 国产亚洲综合久久系列| 久久国产欧美日韩精品| 久久青青草原亚洲av无码app | 中文字幕成人精品久久不卡| 久久精品中文字幕久久| 亚洲嫩草影院久久精品| 久久精品无码免费不卡| 亚洲国产成人乱码精品女人久久久不卡|