#P1849. [USACO12MAR] Tractor S
[USACO12MAR] Tractor S
Description
After a long day of work, Farmer John completely forgot that his tractor was still in the middle of the field. His cows, who love to play pranks on him, dropped hay bales at various positions in the field. This means John must move some hay bales out of the way before he can drive the tractor out.
Both the tractor and the hay bales are treated as points on a two-dimensional plane with integer coordinates. No hay bale shares the same coordinates as the tractor’s initial position. John can drive the tractor only along the coordinate axes for some number of units. For example, he can first move north by units and then east by units, and so on. The tractor cannot move onto a point occupied by a hay bale.
Please help John compute the minimum number of hay bales that must be moved so that he can drive the tractor back to the origin.
Input Format
The first line contains three space-separated integers, giving the number of hay bales and the tractor’s starting coordinates .
Lines through : each line contains two space-separated integers. On line , the integers give the coordinates of the -th hay bale .
Output Format
Output a single integer on one line: the minimum number of hay bales that must be moved so John can drive the tractor back to the origin.
7 6 3
6 2
5 2
4 3
2 1
7 3
5 4
6 4
1
Hint
For of the testdata, it is guaranteed that , .
Translated by ChatGPT 5
京公网安备 11011102002149号