• <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>

            先按題意找出最低點作為起始點,計算出起始向量。然后每次選擇左轉角度最小的點走。一定能走完 n 個點。

            /*************************************************************************
            Author: WHU_GCC
            Created Time: 2007-8-13 19:38:56
            File Name: pku1696.cpp
            Description: 
            ***********************************************************************
            */

            #include 
            <iostream>
            #include 
            <cmath>
            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; }

            typedef 
            struct point_t
            {
                
            int num;
                
            int x, y;
            }
            ;

            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;
            }


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


            int64 dot(
            const point_t &a, const point_t &b)
            {
                
            return int64(a.x) * b.x + int64(a.y) * b.y;
            }


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


            double angle(const point_t &a, const point_t &b)
            {
                
                
            double ret = acos(double(dot(a, b)) / (dist(a) * dist(b)));
                
            return det(a, b) > 0 ? ret : -ret;
            }


            const int maxn = 100;
            point_t p[maxn];
            int used[maxn];

            int main()
            {
                
            int ca;
                
            int n;
                
            for (scanf("%d"&ca); ca--;)
                
            {
                    scanf(
            "%d"&n);
                    
            for (int i = 0; i < n; i++)
                        scanf(
            "%d%d%d"&p[i].num, &p[i].x, &p[i].y);

                    
            int miny = 0x7FFFFFFF, mini;
                    
            for (int i = 0; i < n; i++)
                        
            if (p[i].y < miny)
                        
            {
                            miny 
            = p[i].y;
                            mini 
            = i;
                        }

                    memset(used, 
            0sizeof(used));
                    used[mini] 
            = 1;
                    
            int now = mini;
                    point_t now_vector;
                    now_vector.x 
            = 0;
                    now_vector.y 
            = p[mini].y;
                    printf(
            "%d", n);
                    
            for (int i = 1; i < n; i++)
                    
            {
                        printf(
            " %d", p[now].num);
                        
            double min_alpha = 1e200;
                        
            int minj;            
                        
            for (int j = 0; j < n; j++if (!used[j])
                        
            {
                            
            double t = angle(now_vector, p[j] - p[now]);
                            
            if (t < min_alpha)
                            
            {
                                min_alpha 
            = t;
                                minj 
            = j;
                            }

                        }

                        now_vector 
            = p[minj] - p[now];
                        now 
            = minj;
                        used[minj] 
            = 1;
                    }

                    printf(
            " %d\n", p[now].num);
                }

                
            return 0;
            }
            posted on 2007-08-13 20:46 Felicia 閱讀(496) 評論(0)  編輯 收藏 引用 所屬分類: 計算幾何
             
            久久久久99精品成人片欧美 | 久久亚洲天堂| 亚洲国产精品无码久久一线| 久久免费视频1| 狠狠综合久久AV一区二区三区| 青青草原综合久久| 久久97久久97精品免视看秋霞| 免费一级做a爰片久久毛片潮| 中文字幕久久精品 | 久久久女人与动物群交毛片 | 久久精品亚洲精品国产色婷| 99久久99久久久精品齐齐| 国产成人久久777777| 久久成人国产精品免费软件| 久久久久久综合一区中文字幕| 亚洲精品乱码久久久久久不卡| 精品无码久久久久久尤物| 久久精品视频网| 久久久久久久久波多野高潮| 亚洲狠狠久久综合一区77777| 久久免费的精品国产V∧| 一级A毛片免费观看久久精品| 久久er国产精品免费观看2| 久久亚洲国产最新网站| 色综合久久天天综合| 久久99国产精品99久久| 亚洲精品高清国产一线久久| 中文成人久久久久影院免费观看| 久久最新免费视频| 国产AⅤ精品一区二区三区久久| 人妻久久久一区二区三区| 欧美亚洲国产精品久久| 久久影视综合亚洲| 人妻少妇精品久久| 四虎久久影院| 久久精品青青草原伊人| 久久综合亚洲鲁鲁五月天| 久久无码中文字幕东京热| 久久青青草视频| 日韩精品久久久肉伦网站| 97精品久久天干天天天按摩|