The Rubber Band and the Pegs
A carpenter hammers n pegs into a flat board, each at an integer-coordinate point (x, y).
Two or more pegs may land at the exact same point. The carpenter then stretches an elastic rubber
band around the outside of all the pegs and lets it snap taut, so it forms the smallest loop that
still encloses every peg.
A peg touches the band if the band passes directly over it — this includes every peg sitting at a corner of the loop, but also every peg that happens to lie exactly on a straight stretch of the band between two corners, even though the band doesn't bend there. Pegs strictly inside the loop are not touched.
Two special cases:
- If
n = 1, the band has nowhere to stretch, so it collapses onto that single peg. That peg touches the band, and the band's length is0. - If every peg lies on one straight line, the band can't form a loop around them — it stretches taut from the peg furthest in one direction to the peg furthest in the other direction and back, covering that segment twice. Every peg touches the band in this case, since every peg lies somewhere on that segment.
Given the positions of all n pegs, determine how many of them touch the band, and the total
length of the band.
Input
The first line contains one integer n (1 ≤ n ≤ 2·10^5).
Each of the next n lines contains two integers x y (-10^9 ≤ x, y ≤ 10^9) — the position
of a peg. Pegs may repeat.
Output
Print two lines.
On the first line, print one integer — the number of pegs that touch the band.
On the second line, print one real number — the length of the band. Your answer is accepted if its absolute or relative error is at most 10^-6.
Notes
In the first example, five pegs form a square with one extra peg sitting in the middle of the top edge; that extra peg touches the band even though the band runs straight through it, so 5 of the 6 pegs touch the band.