HDOJ 1348 Wall convex hull

Source: Internet
Author: User

HDOJ 1348 Wall convex hull

 

 

Wall Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission (s): 4001 Accepted Submission (s): 1131



Problem Description Once upon a time there was a greedy King who ordered his chief implements ECT to build a wall around the King's castle. the King was so greedy, that he wocould not listen to his own ect's proposals to build a beautiful brick wall with a perfect shape and nice tall towers. instead, he ordered to build the wall around the whole castle using the least amount of stone and labor, but demanded that the wall shocould not come closer to the castle than a certain distance. if the King finds that the role ECT has used more resources to build the wall than it was absolutely necessary to satisfy those requirements, then the role ect will loose his head. moreover, he demanded effecect to introduce at once a plan of the wall listing the exact amount of resources that are needed to build the wall.
Your task is to help poor revoke ECT to save his head, by writing a program that will find the minimum possible length of the wall that he cocould build the castle to satisfy King's requirements.



The task is somewhat simplified by the fact, that the King's castle has a polygonal shape and is situated on a flat ground. the specified ECT has already established a Cartesian coordinate system and has precisely measured the coordinates of all castle's vertices in feet.

Input The first line of the input file contains two integer numbers N and L separated by a space. N (3 <= N <= 1000) is the number of vertices in the King's castle, and L (1 <= L <= 1000) is the minimal number of feet that King allows for the wall to come close to the castle.

Next N lines describe coordinates of castle's vertices in a clockwise order. each line contains two integer numbers Xi and Yi separated by a space (-10000 <= Xi, Yi <= 10000) that represent the coordinates of ith vertex. all vertices are different and the sides of the castle do not intersect anywhere except T for vertices.

Output Write to the output file the single number that represents the minimal possible length of the wall in feet that cocould be built around the castle to satisfy King's requirements. you must present the integer number of feet to the King, because the floating numbers are not supported Ted yet. however, you must round the result in such a way, that it is accurate to 8 inches (1 foot is equal to 12 inches), since the King will not tolerate larger error in the estimates.

This problem contains multiple test cases!

The first line of a multiple input is an integer N, then a blank line followed by N input blocks. each input block is in the format indicated in the problem description. there is a blank line between input blocks.

The output format consists of N output blocks. There is a blank line between output blocks.

Sample Input
19 100200 400300 400300 300400 300400 400500 400500 200350 200200 200

Sample Output
1628

Source Northeastern Europe 2001

 

 

/*************************************** * ******** Author: CKbossCreated Time: Tuesday, April 07, 2015 File Name: HDOJ1348.cpp *************************************** * *********/# include
 
  
# Include
  
   
# Include
   
    
# Include
    
     
# Include
     
      
# Include
      
        # Include
       
         # Include
        
          # Include
         
           # Include
          Using namespace std; const double eps = 1e-7; int dcmp (double x) {if (fabs (x)
           
             CovexHull (vector
            
              & P) {sort (p. begin (), p. end (); p. erase (unique (p. begin (), p. end (), p. end (); int n = p. size (); int m = 0; vector
             
               Ch (n + 1); for (int I = 0; I
              
                1 & Cross (ch M-1]-ch [m-2], p [I]-ch [m-2]) <= 0) m --; ch [m ++] = p [I];} int k = m; for (int I = n-2; I> = 0; I --) {while (m> k & Cross (ch [s-1]-ch [m-2], p [I]-ch [m-2]) <= 0) m --; ch [m ++] = p [I];} if (n> 1) m --; ch. resize (m); return ch;} int main () {// freopen ("in.txt", "r", stdin); // freopen ("out.txt ", "w", stdout); int T_T; scanf ("% d", & T_T); while (T_T --) {scanf ("% d % lf", & n, & r); vector
               
                 Vp; for (int I = 0; I
                
                  CH = CovexHull (vp); CH. push_back (CH [0]); double ans = 2. * acos (-1.0) * r; int sz = CH. size (); for (int I = 1; I
                 
                  

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.