#P2994. Early Arrival Seating
Early Arrival Seating
Early Arrival Seating
Farmer John's N cows (numbered 1..N) are enjoying their holiday in Bulgaria until dinner time arrives. The dinner hall has only M seats (numbered 1..M). Each cow starts at a specified location \((C_{X_i}, C_{Y_i})\) and each seat is located at \((S_{X_j}, S_{Y_j})\).
The cows use a simple strategy: as soon as a cow is sure that she can reach a particular seat before any other cow, she rushes there in a straight line (all cows run at the same constant speed). The time required for cow i to reach seat j is proportional to the Euclidean distance, given by \[ d_{i,j} = \sqrt{(C_{X_i}-S_{X_j})^2 + (C_{Y_i}-S_{Y_j})^2}. \] Since running speeds are identical, comparing squared distances \((C_{X_i}-S_{X_j})^2+(C_{Y_i}-S_{Y_j})^2\) is sufficient.
When more than one cow can arrive at a seat at exactly the same time, the cow that appears earlier in the input (i.e. the older cow) claims the seat. Likewise, if a cow can be the first to reach multiple seats, she chooses the seat with the lowest seat index (i.e. the earliest in input order).
Some cows may not be able to get any seat. These hungry cows are planning mischief, so Farmer John needs to know which cows to watch out for. If every cow gets a seat, output 0.
inputFormat
The first line contains two integers N and M (1 ≤ M ≤ N ≤ 1000).
The next N lines each contain two integers \(C_{X_i}\) and \(C_{Y_i}\) (\(-10^6 \le C_{X_i}, C_{Y_i} \le 10^6\)), representing the starting coordinates of the cows.
The following M lines each contain two integers \(S_{X_j}\) and \(S_{Y_j}\) (\(-10^6 \le S_{X_j}, S_{Y_j} \le 10^6\)), representing the coordinates of the seats.
outputFormat
If there is at least one cow that does not get a seat, output the indices (1-indexed) of all hungry cows in increasing order, separated by a single space. If every cow gets a seat, output 0.
sample
3 2
0 0
10 10
20 20
0 1
100 100
2