#P3738. [HAOI2014] 穿越封锁线
[HAOI2014] 穿越封锁线
Description
An enemy-occupied area is a closed polygon represented by consecutive vertices , , , .
Our scout ZDM-007 needs to cross the blockade line of the enemy-occupied area. For safety, ZDM-007 travels along a path perpendicular to the -axis, moving from south to north.
Given the current position of ZDM-007, can you compute the total length of his route that lies inside the enemy-occupied area while he crosses the blockade line?

Input Format
The first line: , the number of polygon vertices.
The next lines: , the coordinates of the polygon vertices (given in counterclockwise order).
The last line: , the scout’s initial position.
Output Format
Output the total length of the scout’s path that lies inside the enemy-occupied area while crossing the blockade line. Print only the integer part.
7
0 1
2 0
4 1
2 2
4 3
2 4
0 3
3 -1
2
4
10 100
10 0
100 0
100 100
100 -80
0
Hint
Constraints
$3\le n\le 50, 0\le x_i, y_i \le 1000, 0\le X \le 1000, -100\le Y < 0$.
Translated by ChatGPT 5
京公网安备 11011102002149号