Dalgona
Time limit1sMemory limit1024 MB
Given circles and simple polygons on a plane, count the number of regions the shapes divide the plane into.
- Level
Medium7 of 10
- Topics
- Geometry, Graph, Union-find
- Solved
- No attempts yet
Problem
A dalgona machine has been installed in Lab 512 of building K at Sogang University. Next to the machine are molds in the shape of circles or simple polygons, used for the candy-pulling game. Generally, the shape of the mold determines how hard the game is. However, none of these shapes satisfies Sangwon, the master of the game. The game was too easy, so Sangwon came up with a way to make it harder. If several molds are stamped into one candy, the number of pieces to pull out increases, making the game harder!
Given circles and simple polygons on a two-dimensional plane, write a program that finds the number of regions into which they divide the plane.

Figure 1: The candy shape for the first sample.
Input
The input is given as follows.
-
is the description of each shape.
-
For a circle, is given in the following form.
- A circle with center () and radius . ()
-
For a simple polygon, is given in the following form.
- is the number of vertices of the simple polygon.
- () are the coordinates of each vertex. ()
- The vertices are given in counterclockwise order.
-
Output
Print the number of regions that the shapes divide the plane into.
Constraints
- is the number of shapes. ()
- The sum of the number of edges of all simple polygons and the number of circles does not exceed .
- No point lies on three or more circles or edges.
- All numbers in the input are integers.