K-Convex Hull
Time limit1sMemory limit1024 MB
Given N distinct points, count how many single points can be removed so that the convex hull of the remaining points has exactly K vertices.
- Level
Hard8 of 10
- Topics
- Geometry, Sorting, Divide and conquer
- Solved
- No attempts yet
Problem
Given distinct points on a 2D plane, remove one point. The convex hull of the remaining points must have exactly vertices. Write a program that counts the number of points that can be removed. If several points lie on an edge of the convex hull, only the two endpoints of that edge are counted as vertices.
Input
The first line contains and (, ). The next lines each contain the and coordinates of a point, separated by a space. Every coordinate is an integer with absolute value at most , and all points are distinct.
Output
Print the number of points that can be removed.
Hint
If the remaining points lie on a single line after a point is removed, the convex hull has only two vertices, so that case is not counted.