#P3297. [SDOI2013] 逃考
[SDOI2013] 逃考
Description
The Gaokao is coming again. For those who don’t study hard, this is really bad news. To make Xiao Yang study at home, his relatives decide to stay at his house and watch him: grandpa and grandma, maternal grandparents, uncle, sister-in-law, aunt, and so on.
Xiao Yang can’t stand it anymore. What’s the difference between this life and prison? For his beloved Xiao Hong and for his Dota, he decides to break out!
Assume Xiao Yang’s house is a rectangle with lower-left corner at and upper-right corner at . There are relatives staying inside the rectangle (at distinct positions, and none of them lies on the boundary). Every location in the house is watched by the nearest relative(s):
That is, suppose Xiao Yang is at , relative is at , then the distance from to Xiao Yang is ; relative is at , then the distance from to Xiao Yang is . Since , the position is watched by .
If there are multiple relatives tying for the nearest distance, then that position is watched by all of them simultaneously.
Given Xiao Yang’s starting position . Since the fewer people who discover him, the greater the chance of a successful escape, your task is to design a route from his starting position to the boundary of the rectangle so that the number of people who discover him is minimized.
Xiao Yang may move in any direction; the route can be any continuous path, and all positions along the path may have real coordinates.
It is guaranteed that at the starting position, Xiao Yang is watched by exactly one relative.
Input Format
- The first line contains a positive integer , the number of testdata.
- For each of the testdata:
- The first line contains an integer , the number of relatives.
- The second line contains four positive integers giving the rectangle’s upper-right corner and Xiao Yang’s starting position .
- Each of the next lines contains two positive integers, the position of one relative.
Output Format
For each testdata, output a single positive integer: the minimum possible number of relatives who will discover Xiao Yang during his escape.
2
4
10 10 5 5
5 6
3 5
7 5
5 3
17
14 12 7 6
7 11
6 9
7 7
1 10
2 20
1 6
2 6
1 1
2 2
5 1
5 2
13 1
12 2
12 7
13 7
12 11
13 11
1
2
Hint
Explanation:
- In the first dataset, Xiao Yang goes straight up and is only watched by .
- In the second dataset, Xiao Yang is watched by , goes to where he is watched by , and then goes straight up.
Constraints:
- For the first of the testdata, .
- For the remaining testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号