#C11604. Taco: Dividing Points with a Straight Line
Taco: Dividing Points with a Straight Line
Taco: Dividing Points with a Straight Line
You are given a set of points in the Cartesian plane. Each point is described by its coordinates (x, y) and a unique label. For a given query with label k, your task is to determine whether it is possible to draw a straight line passing through the point with label k such that the remaining points are divided equally on both sides of the line.
Note that in order to split the set of points into two equal halves, the total number of points, n, must be even. In other words, the necessary and sufficient condition is:
\( n \mod 2 = 0 \)
If this condition is met, then the answer is always YES
irrespective of the coordinates and the starting point; otherwise, the answer is NO
.
You need to process multiple queries where each query provides a label k and output the result accordingly.
inputFormat
The input is given from stdin in the following format:
n q x1 y1 label1 ... xn yn labeln query1 ... queryq
Here:
n
is the number of points.q
is the number of queries.- The next
n
lines contain three integers each, representing the coordinates (x, y) and a unique label for each point. - The following
q
lines each contain a labelk
representing the starting point for the query.
outputFormat
For each query, output a single line to stdout with either YES
if it is possible to draw a straight line meeting the condition, or NO
if it is not possible.
The result for each query should be printed on a separate line.
## sample4 3
1 2 1
3 4 2
5 6 3
7 8 4
1
2
3
YES
YES
YES
</p>