You can see the problem here.
Every two circles touch in at most one point (in particular no circle can be contained in a different circle).
Does anyone have some ideas about the problem?
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | Dominater069 | 154 |
8 | awoo | 154 |
10 | luogu_official | 150 |
You can see the problem here.
Every two circles touch in at most one point (in particular no circle can be contained in a different circle).
Does anyone have some ideas about the problem?
Name |
---|
Well, you coul build a Voronoi diagram of the set of centers of circles, and then check every adjacent (by edges) pair of circles in the diagram (O(n)), just check that the sum of radious is the same as the distance between the center, if radii are integer such a check can even be made in integers.
Now it appears to me that no circle Y con be ok for a circle X if it isn't its neighbour, without violating the property of only one point of intersection with some neighbour of X.
Of course writing a voronoi working in time for 500000 points may prove challenging, so if you do that, you let me see your code after that, I've never implemented O(nlogn) Voronoi myself :)
Sorry in advance if there is any mistake with this solution, and perhaps there is a simpler solution.
Thanks for sharing your ideas.
You are welcome
It is a quite standard sweep line problem.
Sweep with a vertical line from left to right. There are 2 types of events: a circle began, a circle ended.
Maintain a set of circles that the line currently intersects (began, but not ended). In this set, maintain them sorted by Y coordinate of their center. Then each time you add a circle, you only need to check at most 2 of it's neighbors (for having a common point with it). The same when you delete a circle, there could be at most one new pair of neighbors formed that you need to check.
What you have to be careful with:
Wow, Thanks a lot.