GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Tuesday, 6 September 2022

[Solution] Mainak and the Bleeding Polygon Codeforces Solution


H. Mainak and the Bleeding Polygon
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Mainak has a convex polygon P with n vertices labelled as A1,A2,,An in a counter-clockwise fashion. The coordinates of the i-th point Ai are given by (xi,yi), where xi and yi are both integers.

Further, it is known that the interior angle at Ai is either a right angle or a proper obtuse angle. Formally it is known that:

  • 90Ai1AiAi+1<180i{1,2,,n} where we conventionally consider A0=An and An+1=A1.

Mainak's friend insisted that all points Q such that there exists a chord of the polygon P passing through Q with length not exceeding 1, must be coloured red.

Mainak wants you to find the area of the coloured region formed by the red points.

Formally, determine the area of the region S={QP | Q is coloured red}.

Recall that a chord of a polygon is a line segment between two points lying on the boundary (i.e. vertices or points on edges) of the polygon.

Input

The first line contains an integer n (4n5000) — the number of vertices of a polygon P.

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

The i-th line of the next n lines contain two integers xi and yi (109xi,yi109) — the coordinates of Ai.

Additional constraint on the input: The vertices form a convex polygon and are listed in counter-clockwise order. It is also guaranteed that all interior angles are in the range [90;180).

Output

Print the area of the region coloured in red.

Your answer is considered correct if its absolute or relative error does not exceed 104.

Formally, let your answer be a, and the jury's answer be b. Your answer is accepted if and only if |ab|max(1,|b|)104.

No comments:

Post a Comment