#P4460. Unlock Pattern Count

    ID: 17706 Type: Default 1000ms 256MiB

Unlock Pattern Count

Unlock Pattern Count

You are given a set of n distinct points on the plane. In a new unlock screen design, these points can be placed arbitrarily (i.e. they are no longer arranged in a fixed grid), but the following drawing rules remain:

  • The pattern must connect at least \(4\) points.
  • A line segment connecting two points must be a straight line (i.e. no bending in between).
  • Each point can be used at most once in the pattern.
  • When drawing a segment between two points \(A\) and \(B\), if there exists any other point \(C\) that lies exactly on the straight line segment between \(A\) and \(B\), then the segment \(A\rightarrow B\) is valid only if \(C\) has already been used previously in the pattern. In other words, you cannot "jump over" a point that has not been visited yet. For example, in a typical three‐by‐three grid, the move \(1\rightarrow 3\) is valid only if \(2\) has already been used.

Your task is to count the total number of valid patterns on the unlock screen.

Note: A valid pattern is any sequence of distinct points (of length at least 4 and at most n) such that every consecutive pair of points follows the rule regarding intermediate points. The intermediate point \(C\) is defined as a point that is collinear with and lies strictly between the two endpoints. Collinearity should be determined using the standard cross product check and bounding box test.

inputFormat

The input begins with an integer n (\(4 \le n \le 10\)), the number of points. The next n lines each contain two numbers representing the coordinates of a point. The points are guaranteed to be distinct. It is not guaranteed that no three points are collinear.

For example:

4
0 0
0 1
1 0
1 1

outputFormat

Output a single integer denoting the total number of valid unlock patterns.

sample

4
0 0
0 1
1 0
1 1
24