Given n circles n <= 1000, how can I find the area of union of all this circles?

# | User | Rating |
---|---|---|

1 | tourist | 3434 |

2 | OO0OOO00O0OOO0O0…O | 3280 |

3 | Syloviaely | 3274 |

4 | Petr | 3233 |

5 | Um_nik | 3213 |

6 | ko_osaga | 3124 |

7 | Benq | 3105 |

8 | Swistakk | 3092 |

9 | fjzzq2002 | 3055 |

10 | anta | 3053 |

# | User | Contrib. |
---|---|---|

1 | Radewoosh | 173 |

2 | rng_58 | 162 |

3 | tourist | 159 |

4 | Petr | 153 |

5 | Swistakk | 152 |

6 | csacademy | 151 |

7 | Vovuh | 145 |

7 | Um_nik | 145 |

9 | Errichto | 144 |

10 | PikMike | 143 |

Given n circles n <= 1000, how can I find the area of union of all this circles?

↑

↓

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Aug/22/2018 07:25:15 (f1).

Desktop version, switch to mobile version.

User lists

Name |
---|

I'm interested in that kind of problem too..! http://www.spoj.pl/problems/VCIRCLES/ is a small version but the big one is http://www.spoj.pl/problems/CIRU/

The main idea here is to make a vertical decomposition: draw a vertical line through every point of two circles' intersection and through two points with maximal and minimal x of every circle. Hence, you'll have O(N^2) vertical bands. In each band you have something like brackets (arcs) sequence so you can skip inner brackets. At last, you have some trapezoids with arc as side edges. Their area can be easily found in many ways.

please describe any of them....

How do you do the "easy" part in less than O(N)? :)

There is a way, I think. But I never implemented it myself. You can try to build planar graph where vertices are points of circles intersections and edges are arcs. Then you can use standard algorithm for finding the area of faces of the planar graph. The only problem is how to sort edges, connected to one vertex. I am not sure about how do it correctly.

are there questions based on area similar to this on CodeForces?

You can try this (not exactly same but similar): https://codeforces.com/contest/814/problem/D

This problem can be solved with Green’s Theorem : Find the arcs which lies in the border of the union of area (in n^2lgn time with sweep), and apply the formula directly.