-->
当前位置:首页 > 题库

PROGRAMMING:the Great Wall

Luz5年前 (2021-05-10)题库336
As we all know, the ancient Great Wall of China was built to resist foreign invasion. Many beacon towers were built on the Great Wall. Each beacon is monitoring a specific area. Once a certain area is invaded by foreign enemies, the soldiers on duty at the corresponding beacon will report the enemy situation to the surrounding beacon, and quickly relay it to the headquarters.
Now, as shown in Figure 1, if the horizontal direction is north-south and the vertical direction is altitude, suppose that the Great Wall is a series of line segments connected in turn, and any vertical line within this range has and only has a unique intersection with these line segments.
![](~/ 184)
**Figure 1**
Furthermore, it is assumed that the beacon tower can only be built at the end of the line segment. We think that the beacon itself has no height. Each beacon is only responsible for looking to the North (left in Figure 1), and once there is an invasion by foreign enemies, as long as there is no mountain between the enemy and the beacon, the Sentry will immediately detect it. Of course, according to this military regulation, we are not responsible for the enemy's situation in the south. Once the sentry finds out the enemy's situation, he will immediately send the alarm to the beacon tower in the south in the form of wolf smoke or beacon fire, until the headquarters located in the southernmost side.
Taking the Great Wall in Figure 2 as an example, the four beacon towers in charge of guarding are indicated by blue and white dots, and the southernmost headquarters is indicated by red dots. If there is an enemy situation in the place marked by the red star, the Sentinels will find it and send the alarm to the headquarters along the red broken line. Of course, in this case, only the cooperation of two beacon towers is needed, but the enemy situation in other locations may need more.
However, on the other hand, even if the four beacon towers here are all involved, there are still areas that cannot be covered.
![](~/ 185)
**Figure 2**
In addition, to avoid ambiguity, we agree here that the area just tangent to the line of sight of a beacon can be monitored by the beacon. Taking the Great Wall in Figure 3 as an example, if points a, B, C and D are collinear, and a beacon tower is set at point D, then any point on a, B, C and segment BC is within the monitoring range of the beacon tower.
![](~/ 186)
**Figure 3**
Well, if you are the first emperor of Qin Dynasty's Taiwei, in order to avoid more tragedies of Mengjiang women, how to ensure the safety of the great wall and minimize the consumption of civil resources (beacon towers built)?
###Input format:
Enter a positive integer 'n' (3 $$$Le $$'n '$$Le 10 ^ 5 $$) in the first line, and immediately draw the number of broken line vertices (including start and end points) on the edge of the Great Wall. Next, there are 'n' rows. Each row gives the 'x' and 'y' coordinates of a vertex, separated by a space. Notice that the vertices are given from south to north. The first vertex is the location of the headquarters. The coordinates are integers in the interval $$[- 10 ^ 9, 10 ^ 9) $, and there are no coincidence points.
###Output format:
Output the minimum number of beacon towers (excluding headquarters) to be built in one line.
###Input example:
```in
ten
67 32
48 -49
32 53
22 -44
19 22
11 40
10 -65
-1 -23
-3 31
-7 59
```
###Output example:
```out
two
```






answer:If there is no answer, please comment