#P3122. [USACO15FEB] Fencing the Herd G
[USACO15FEB] Fencing the Herd G
Description
Farmer John needs your help deciding where to build a fence shaped as an infinitely long straight line to restrict the movement of his cows. He has selected several candidate positions for building the fence, and you need to determine which fences are useful. A fence is useful if and only if all cows lie on the same side of the fence. If any cow lies exactly on the fence line, then the fence is useless. Farmer John will ask you multiple times whether a fence is useful; for each query, output YES if the fence is useful, otherwise output NO.
Additionally, Farmer John may bring in new cows to join the herd. After a cow joins, it must be considered in all subsequent queries and must also lie on the same side of the fence as the other cows.
Input Format
The first line contains two positive integers , the initial number of cows and the number of queries.
The next lines each contain two integers , the initial positions of the cows.
The next lines each describe a query in one of the following formats:
- 1 : a new cow joins the pasture at .
- 2 : Farmer John asks whether the fence is useful.
Output Format
For each query of type , output YES if the fence is useful, otherwise output NO.
3 4
0 0
0 1
1 0
2 2 2 3
1 1 1
2 2 2 3
2 0 1 1
YES
NO
NO
Hint
The line places all three initial cows on the same side; however, adding the cow on the other side makes it useless.
The line is useless because cows and lie exactly on it.
Constraints.
For of the testdata, it is guaranteed that , , all cows have distinct coordinates and satisfy , , .
It is guaranteed that there is no fence with .
Translated by ChatGPT 5
京公网安备 11011102002149号