Safe Zone
Time limit9sMemory limit2048 MB
Given N axis-aligned rectangles, group them into alliances where rectangles connect through shared points, and report the groups.
- Level
Medium7 of 10
- Topics
- Segment tree, Union-find, Sorting
- Solved
- No attempts yet
Problem
Due to a zombie virus, the Earth has been destroyed, and only military units survive. The Earth is a rectangular region in coordinate space that satisfies . Each military unit manages a rectangular safe zone. Specifically, for , the -th unit manages the interior and boundary of the rectangle as its safe zone.
Two military units are connected if there is a point contained in both of their safe zones. If and are connected, and and are connected, for distinct , then and are also connected. A set of military units is called an alliance if every unit in the set is connected to the others, and no unit in the set is connected to any unit outside the set.
Constraints
- for all
- ,