PivotOJ

Convex Hull Extension

시간 제한: 4000ms메모리 제한: 1024MB출처: ICPC ECNA 2023-2024BOJ 30526

문제

Dr. Hugh Klidd is a geometry expert who has recently become preoccupied with convex hulls. Recall that for a set of points in the x-yx\textrm{-}y plane, the convex hull is the smallest convex polygon containing all of those points. (A convex polygon has the property that for any two points on/in the polygon, the line segment connecting those two points lies entirely on/in the polygon.) Dr. Klidd has just computed the convex hull of a set of points,S,\textrm{points,} S, which he denotes H(S),H(S), and is quite pleased with the result:

  • the convex hull has n3n \geq 3 vertices
  • each vertex has integer coordinates
  • no three of the convex hull vertices are collinear, i.e., lie on the same line

Dr. Klidd is ambitious, though, so he wants this convex hull to grow. Specifically, he is looking for an extension point, which is a point p=(x,y)p=(x,y) satisfying the following conditions:

  1. xx and yy are integers
  2. if S=S{p}S' = S \cup \{ p \} (SS with pp added), then the convex hull of S,S', i.e., H(S),H(S'), has n+1n+1 vertices
  3. no three of these n+1n+1 vertices are collinear

In other words, an extension point increases the number of convex hull vertices by1,\textrm{by} 1, while still keeping all its nice properties. For most convex hulls, H(S),H(S), Dr. Klidd can usually find at least one extension point, but he would like to know how many extension points there are to choose from. He postulates that there is an efficient way to count the number of extension points, but having never taken an algorithms course, he turns to you for help.1

Figure C.1: Illustration of an extension point for Sample Input 1


1Dr. Klidd has postulated exactly four things before now, so this is his fifth postulate.

입력

The first line of input contains an integer, n,n, the number of vertices of the convex hull that Dr. Klidd starts with (3n50).(3 \leq n \leq 50). This is followed by nn lines, each of which contains two space-separated integers, the xx and yy coordinates of one of the nn vertices (1000x,y1000).(-1\,000 \leq x,y \leq 1\,000). The nn points are distinct, no three are collinear, and they are given in counterclockwise order.

출력

If the number of extension points for the convex hull specified in the input is infinite, output "infinitely many". Otherwise, output the number of extension points.

예제

예제 1

입력
5
0 2
-2 0
-1 -3
1 -3
2 1
출력
23

예제 2

입력
4
-7 -7
7 -7
7 7
-7 7
출력
infinitely many
코드를 제출하려면 로그인하세요.