Laser Trap
Time limit2sMemory limit1024 MB
Find the fewest generators to remove so that the origin lies outside the convex hull of the remaining points.
- Level
Medium6 of 10
- Topics
- Geometry, Sorting, Two pointers
- Solved
- No attempts yet
Problem
BaoBao is playing the famous game Elden Ring these days. It is an open-world game in which you control your character to travel between places. However, your character can also fall into a trap, and you need to figure out how to escape. Right now, BaoBao's character is stuck in a 2-dimensional plane with deadly lasers. There are laser generators, and each generator is a point. Every pair of generators shoots a laser beam between them, so there are beams in total. Each beam starts and ends at generator points and does not extend to infinity.
Starting at , BaoBao wants to escape to without touching any laser beam or generator. To do so, BaoBao can ask her friend DreamGrid to remove any number of generators, along with every beam that starts or ends at a removed generator. Find the minimum number of generators that must be removed for the escape. BaoBao does not need to move in a fixed direction, and her escape route can be a curve if needed.
Input
There are multiple test cases. The first line contains an integer , the number of test cases. Each test case is given as follows.
The first line contains an integer (), the number of laser generators. The next lines contain two integers and (), the location of the -th generator.
No two generators coincide, and no laser beam or generator touches . The sum of over all test cases does not exceed .
Output
For each test case, output one line containing the minimum number of generators that must be removed.
Hint
The figures for the second and third test cases are shown below. Solid dots and solid lines are the remaining generators and beams. Hollow dots and dashed lines are the removed generators and beams. The arrow is the escape route.
