Karelian Fortune Telling
Time limit1sMemory limit1024 MB
Count convex K-gons with vertices chosen from N points in general position, answering several values of K.
- Level
Medium7 of 10
- Topics
- Combinatorics, Geometry, Dynamic programming, Sorting
- Solved
- No attempts yet
Problem
Yukka loves to tell fortunes from the stars, but the sky is often cloudy, so a map of the starry sky is used instead. The map shows stars. To tell a fortune, one must choose of the stars, and if the polygon whose vertices are these points is convex, the fortune telling is considered successful. A polygon is convex if, for the line passing through each of its sides, all of its vertices lie on one side of that line or on the line itself.
Pekka, watching Yukka tell fortunes, wanted to know how many different convex -gons can be built by choosing their vertices from the given points.
Your task is to answer this question for several possible values of .
Input
The first line of the input contains two numbers: the number of points and the number of cases to consider (, ). The next lines contain two integers , each: the coordinates of the points (). No three points lie on one line, and no two points coincide.
You must count the number of convex polygons for different values of , listed in the last line. All numbers are positive integers, each at least three and at most .
Output
In the first line, output numbers separated by spaces: the answers for each case.