Mock CCC '22 2 S4 - Kaguya Wants to Build a Great Wall

View as PDF

Submit solution


Points: 15 (partial)
Time limit: 8.0s
Memory limit: 1G

Problem type

Kaguya is overseeing the construction of a new polygonal wall to protect Shuchi'in Academy from outsiders. The construction of the wall is as follows - Kaguya has hired N workers. Kaguya will draw an N-sided simple polygon, and then each worker will be responsible for building exactly one of the sides of the polygon. Each side of the polygon must have positive length.

The workers are very peculiar. Each worker owns an infinite line in the plane and will only build a side of the polygon if that side lies entirely on the infinite line the worker ones.

Compute the number of distinct walls that can be built. Two walls are distinct if and only if there is some point present in one wall that is not part of the other.

Constraints

3 \le N \le 12

|x_i|, |y_i| \le 2000

All lines will be distinct.

In tests worth 1 mark, N = 3.

In tests worth 1 mark, N = 4.

In tests worth 1 mark, N = 5.

In tests worth 1 mark, N = 6.

In tests worth 1 mark, N = 7.

In tests worth 1 mark, N = 8.

In tests worth 1 mark, N = 9.

In tests worth 1 mark, N = 10.

In tests worth 1 mark, N = 11.

Input Specification

The first line contains an integer N.

Each of the next N lines contains four integers, x_1, y_1, x_2, and y_2, two points on the infinite line that the given worker owns.

Output Specification

Output the number of distinct polygons that can be constructed.

Sample Input 1

4
0 0 0 1
0 0 1 0
0 2 1 0
2 0 0 1

Sample Output 1

2

Sample Input 2

7
0 0 0 1
1 0 1 1
2 0 2 1
0 0 1 0
0 1 1 1
0 2 1 2
0 3 1 3

Sample Output 2

0

Sample Input 3

4
0 1 0 -1
1 0 -1 0
1 1 -1 -1
1 -1 -1 1

Sample Output 3

0

Comments

There are no comments at the moment.