#P8513. Pair Count Under Linear Constraint
Pair Count Under Linear Constraint
Pair Count Under Linear Constraint
Given n points of the form \( (x_i, y_i, c_i) \) for \( i=1,2,\dots,n \), and m queries, each query provides constants \( A \), \( B \), and \( C \). For each query, count the number of unordered pairs \( (i, j) \) (with \( i < j \)) such that:
\( A \cdot x_i + B \cdot y_i + C < 0 \),
\( A \cdot x_j + B \cdot y_j + C < 0 \),
and \( c_i = c_j \).
Output the count for each query.
inputFormat
The first line contains two integers n and m representing the number of points and the number of queries.
The next n lines each contain three integers \( x_i \), \( y_i \), and \( c_i \).
The following m lines each contain three integers \( A \), \( B \), and \( C \) describing a query.
outputFormat
For each query, output a single line containing the number of unordered pairs \( (i, j) \) satisfying the conditions.
sample
3 1
1 2 1
3 4 1
5 6 2
1 1 -10
1