시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 21 6 6 37.500%

문제

Farmer Bob’s horses all are hoarse and may have a cold - even the pony is a little hoarse! Because of that, all the farm animals need to be individually quarantined. To separate the animals, Farmer Bob has a set of n fences that cannot be crossed. Unfortunately, Farmer Alice has taken all of Farmer Bob’s fences and placed them arbitrarily in the plane! Farmer Bob has no time to rearrange these fences - he must leave them as is.

Help Farmer Bob calculate how many of his prized barnyard animals he can quarantine. That is, Farmer Bob wants to place as many animals inside non-empty regions enclosed by the fences, such that no animal can reach another animal, and no animal can escape to infinity.

Each fence is given by a line segment between two points. It is given that no three fences go through the same point. Fences are allowed to cross each other.

입력

  • A single integer 1 ≤ n ≤ 1000, the number of fences.
  • Then n lines follow, each with four integers −109 ≤ x1, y1, x2, y2 ≤ 109. These are the endpoints of the fences, each fence is given by a straight line segment between two endpoints.

출력

Output a single line containing a single integer c, the maximum number of animals Farmer Bob can quarantine.

예제 입력 1

1
1 1 1 2

예제 출력 1

0

예제 입력 2

4
1 0 1 5
4 0 4 5
0 1 5 1
0 4 5 4

예제 출력 2

1

예제 입력 3

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

예제 출력 3

4

힌트

Figure 4: Illustration of the third example input.