Concentric Circles
Time limit2sMemory limit1024 MB
Two families of concentric circles have distinct centers; count the bounded regions that all the circles form together.
- Level
Medium7 of 10
- Topics
- Math, Geometry, Binary search
- Solved
- No attempts yet
Statement
Space invaders once again sent an expedition to Earth. To intimidate the local population, they decided to draw circles in the fields.
The invaders picked a point on the field and drew circles centered at this point with radii . Then they drew circles centered at another point with radii .
The people of Earth are not especially wary of visitors from space, but just in case, they want to know how many regions bounded by the circle lines drawn by the invaders appeared on the field.
Input
The first line contains two integers and ().
The second line contains an integer (). It is followed by integers in strictly increasing order ().
The third line contains two integers and (). It is guaranteed that the points and are distinct.
The fourth line contains an integer (). It is followed by integers in strictly increasing order ().
Output
Print one number: the number of regions formed by the circles, not counting the outer region.
Hint
In the first example, the regions look as follows:
