Tyvj 1150 rope perimeter pick theorem anti-overflow Policy

Source: Internet
Author: User

P1150-rope perimeter from 332404521 Normal (OI)
Total time limit: 10 s memory limit: 128 MB code length limit: 64 kB background recently, yunyu is studying plane ry. I cannot think of a problem, so find Daniel and you will help him. Description Description: N points on the plane are given. The coordinates of all points are integers. The catfish uses a rope to enclose all the points in a closed graph, and the length of the rope is the shortest. After the encirclement is completed, ainemo wants to know how many points (including the given n points and the ungiven points) are enclosed by the total horizontal and vertical coordinates of the rope, the point where the rope passes is included), but when the point is full of planes, the catfish fainted>. <. The input format is inputformat. The first line is an integer n (n <= 200000), indicating the number of vertices.
The following n rows have two integers, XI and Yi (all in the longint range), representing the coordinates of the I point. Output Format: An outputformat line. An integer indicates the number of vertices enclosed by the rope. Sample input sampleinput [Copy Data]
 
4
-1-1
1 3
3 1
1 1
Sample output sampleoutput [Copy Data]
 
10
The shortest method of data range and comment hint is the triangle with three vertices (-1,-1), (3, 1), (1, 3) respectively.
The ropes enclose the following points:
(-1,-1 ), (1, 3)
10 in total.

The answer may be out of the longint range. int64 or long is required. Source catfish pick theorem s = I + (A/2)-1; S indicates the area, I indicates the interior vertices of the polygon, and a indicates the edges; A is calculated using GCD. Pay attention to the case of 0. This question is a question with a large amount of data that is prone to long overflow. The following is a summary of these questions:
    1. The Int subtraction in the two [-1e9, 1e9] will overflow, and it mainly appears in the geometric problem.
    2. If there is a subtraction operation in the modulo question, you must change it to a positive number.
    3. Data range of 1e9 should not use double

Tyvj 1150 rope perimeter pick theorem anti-overflow Policy

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.