Chords
Hard
Execution time limit is 1 second
Runtime memory usage limit is 122.174 megabytes
One draws n chords in a circle and cut in along the received lines. How many parts shall we get from the circle?
It is known that the chord's endpoints are different, no 3 chords intersects at one point.
Input
The first line contains the number of chords n (1 ≤ n ≤ 30 000). Each of the next n lines contains two numbers a[i]
and b[i]
(0 ≤ a[i]
, b[i] < 360
) with accuracy of three digits after the decimal point - the polar angles of the initial and final points the next chord. The start of the polar coordinate system is located in the center of the circle.
Output
Print the number of parts into which the circle is cut.
Examples
Input #1
Answer #1
Submissions 772
Acceptance rate 5%