Circle Regions
Time limit1sMemory limit256 MB
Count how many regions N circles with centers on the x-axis and no crossings cut the plane into.
- Level
Medium7 of 10
- Topics
- Stack, Sorting, Union-find, Math
- Solved
- No attempts yet
Problem
There are circles on the x-axis. Every center lies on the x-axis, and no two circles cross each other. They may touch.
Write a program that counts how many regions the circles cut the plane into.
A region is a set of points, and any two points in it can be joined by a continuous curve that never meets a circle. The unbounded part outside every circle counts as one region.

Input
The first line contains the number of circles ().
Each of the next lines contains one circle as two integers and . is the x coordinate of the center and is the radius. (, )
No circle is given twice.
Output
Print the number of regions the circles make.