[USACO OPEN 2021 G]Permutation
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Bessie has favorite distinct points on a grid, no three of which are collinear. For each , the i-th point is denoted by two integers and .
Bessie draws some segments between the points as follows.
  1. She chooses some permutation of the points.
  2. She draws segments between and and , and and .
  3. Then for each integer ii from 4 to N in order, she draws a line segment from pi to pj for all such that the segment does not intersect any previously drawn segments (aside from at endpoints).

Bessie notices that for each i, she drew exactly three new segments. Compute the number of permutations Bessie could have chosen on step 1 that would satisfy this property, modulo .


输入描述:

The first line contains N.
Followed by N lines, each containing two space-separated integers and .

输出描述:

The number of permutations modulo 
示例1

输入

复制
4
0 0
0 4
1 1
1 2

输出

复制
0

说明

No permutations work.
示例2

输入

复制
4
0 0
0 4
4 0
1 1

输出

复制
24

说明

All permutations work.
示例3

输入

复制
5
0 0
0 4
4 0
1 1
1 2

输出

复制
96

说明

One permutation that satisfies the property is (0,0),(0,4),(4,0),(1,2),(1,1). For this permutation,

First, she draws segments between every pair of (0,0),(0,4), and (4,0).Then she draws segments from (0,0),(0,4), and (4,0) to (1,2).Finally, she draws segments from (1,2), (4,0), and (0,0) to (1,1).

Diagram:

The permutation does not satisfy the property if its first four points are (0,0), (1,1), (1,2), and (0,4) in some order.

备注:

Test cases 1-6 satisfy N≤8.Test cases 7-20 satisfy no additional constraints.

Problem credits: Benjamin Qi