The Forest of Fangorn
Since entering Fangorn Forest, Gimli the dwarf feels uncomfortable. There is something wrong with the trees here! Therefore, Gimli wants to reach one of the camps at the edge of the forest. However, in order to feel safe, at any time Gimli needs to see all trees. Fortunately, dwarves have very good eyes: they can see infinitely far and into every direction.
Fangorn Forest forms a rectangle
From any camp Gimli can see all trees. At the beginning he is located in the interior of the forest, but not on a tree's position (dwarves do not climb trees), and he can see all camps and all trees. Since the Forest of Fangorn is very old, there are no three trees lying on a common line.
Gimli can safely reach a camp
Input Specification
The first line contains two integers
The third line contains an integer
The line after that contains an integer
Output Specification
The first line should contain the number
Subtasks
For all testcases
Subtask # | Weight | Condition |
---|---|---|
Subtask 1 | 30% | |
Subtask 2 | 20% | The trees form the corners of a convex polygon and |
Subtask 3 | 30% | |
Subtask 4 | 20% | No additional constraints. |
Sample Input 1
9 4
1 2
3
7 4
1 4
0 2
4
1 1
6 1
3 3
8 3
Sample Output 1
2
1 3
Explanation for Sample Output 1
The situation of the first testcase together with possible paths from Gimli's starting position
Note that Gimli is allowed to leave the forest during his path. However, even outside the forest he must see all trees—otherwise he would be able to reach the second camp, too.
Sample Input 2
9 4
1 2
1
8 4
4
1 1
6 1
3 3
4 3
Sample Output 2
0
Comments