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

            coreBugZJ

            此 blog 已棄。

            Summer holiday, 1005, 2011 Multi-University Training Contest 10

            Summer holiday

            TimeLimit: 1 Second   MemoryLimit: 32 Megabyte

            Totalsubmit: 434   Accepted: 108  

            Description

            Summer holiday was coming! Xiaomao went back to his hometown where he yearn day and night, his hometown has picturesque scenery. There is a big forest beside his village. There are n trees in the forest.
            Now they want to across the forest with a rope (the rope won't cross). Try to find 3 trees in this tree on the rope which can make the area of the surrounded largest. Work out the area of it.


            Input

            The input will consist of several test cases. The first line contains a positive integer N(3<=N<=10^6), the number of trees, followed N lines, each gives the (xi, yi ) coordinates.


            Output

            Print the largest area, one number a line with two decimal places.


            Sample Input

            4
            0 0
            1 1
            0 1
            1 0


            Sample Output

            0.50


            Source

            [p][/p]




            二維凸包


            不做 ACM 三個月了,心血來潮參加了練習賽,悲劇的沒有準備模板,這個模板是臨時從網上搜來的,非原創。


              1 #include<iostream>
              2 #include<cstdio>
              3 #include<cmath>
              4 #include<cstdlib>
              5 #include<algorithm>
              6 
              7 using namespace std;
              8 
              9 struct P{
             10         double x,y;
             11 };
             12 
             13 #define  EPS  0.00001
             14 #define  ZERO(x)   ( (x<EPS) && ((-(x))<EPS) )
             15 
             16 const int L = 2000009;
             17 P p[ L ], stack[ L ];
             18 int n, top;
             19 
             20 inline double Mul(P p1,P p2,P p3) 
             21 {    
             22         return (p2.x-p1.x)*(p3.y-p1.y)-(p2.y-p1.y)*(p3.x-p1.x); 
             23 }
             24 
             25 inline double dis(P a,P b)
             26 {
             27         return sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
             28 }
             29 
             30 int cmp(const void *a,const void *b)
             31 {
             32         P * c = (P *)a;
             33         P * d = (P *)b;
             34         double k = Mul(p[0],*c,*d);
             35         if(k<0 || (!&& dis(*c,p[0]) > dis(*d,p[0]) ) )
             36                 return 1;
             37         return -1;
             38 }
             39 
             40 inline void tubao(int n,int &top)
             41 {
             42         int i;
             43         top = 2;
             44         stack[0= p[0];
             45         stack[1= p[1];
             46         stack[2= p[2];
             47         for(i=3;i<=n;i++)
             48         {
             49                 while(Mul(stack[top-1],stack[top],p[i])<=0 && top>=2)
             50                         top --;
             51                 top ++;
             52                 stack[top] = p[i];
             53         }
             54 }
             55 
             56 inline double displ( P p, P l0, P l1 ) {
             57         double t = ( (p.x-l0.x)*(l1.x-l0.x) + (p.y-l0.y)*(l1.y-l0.y) ) / ( dis(l0,p) * dis(l0,l1) );
             58         return dis(p,l0) * sqrt( 1 - t * t );
             59 }
             60 
             61 inline double area( P a, P b, P c ) {
             62         return dis(a,b) * displ(c,a,b) / 2;
             63 }
             64 
             65 double solve() {
             66         int i, j, k;
             67         double ans = 0, anstmp;
             68         for ( i = 0; i < top; ++i ) {
             69             for ( j = i + 1; j < top; ++j ) {
             70                 for ( k = j + 1; k < top; ++k ) {
             71                     anstmp = area( stack[ i ], stack[ j ], stack[ k ] );
             72                     if ( anstmp > ans ) {
             73                         ans = anstmp;
             74                     }
             75                 }
             76             }
             77         }
             78         return ans;
             79 }
             80 
             81 int main()
             82 {
             83         int i,tar;
             84         double x,y;
             85         P temp;
             86         while( scanf("%d",&n) == 1) {
             87                 tar = 0;
             88                 x = y = 0x7FFFFFFF;
             89                 for(i=0;i<n;i++)
             90                 {
             91                         scanf("%lf %lf",&p[i].x,&p[i].y);
             92                         if(p[i].x<|| p[i].x==&& p[i].y<y)
             93                         {
             94                                 x = p[i].x;
             95                                 y = p[i].y;
             96                                 tar = i;
             97                         }
             98                 }
             99                 temp = p[tar];
            100                 p[tar] = p[0];
            101                 p[0= temp;
            102                 qsort(p+1,n-1,sizeof(p[0]),cmp);
            103                 p[n] = p[0];
            104                 tubao(n,top);
            105                 printf( "%0.2lf\n", solve() );
            106         }
            107         return 0;
            108 }
            109 

            posted on 2011-08-11 17:33 coreBugZJ 閱讀(252) 評論(0)  編輯 收藏 引用 所屬分類: ACMAlgorithm

            精品一久久香蕉国产线看播放| 久久国产视频99电影| 久久精品国产清自在天天线 | 久久久久久久久久久久久久| 久久亚洲日韩看片无码| 人妻少妇久久中文字幕| 狠狠色丁香婷婷综合久久来来去| 一级a性色生活片久久无| 久久亚洲AV成人无码国产| 久久本道久久综合伊人| 亚洲精品无码久久久久sm| 国产精品九九久久精品女同亚洲欧美日韩综合区 | 无码人妻精品一区二区三区久久久| 91久久精品91久久性色| 伊人久久大香线蕉成人| 国产精品岛国久久久久| 精品熟女少妇AV免费久久| 91精品国产91热久久久久福利 | 国产精品久久久久一区二区三区| 亚洲国产精品无码久久青草| 嫩草影院久久国产精品| 亚洲国产精品无码久久一线| 欧美精品福利视频一区二区三区久久久精品 | 久久精品青青草原伊人| 伊人久久大香线焦综合四虎| 久久久亚洲欧洲日产国码aⅴ| 狠狠精品干练久久久无码中文字幕| 久久露脸国产精品| 国内精品免费久久影院| 久久精品国产99国产精品澳门| 久久久久久夜精品精品免费啦| 久久久久亚洲av成人无码电影| 国产 亚洲 欧美 另类 久久 | 亚洲国产日韩欧美久久| 91精品国产91热久久久久福利| 精品熟女少妇a∨免费久久| 久久夜色精品国产网站| 亚洲成色www久久网站夜月| 久久久免费观成人影院| 久久香蕉超碰97国产精品| 午夜精品久久久久久99热|