#P9996. [Ynoi2000] hpi

[Ynoi2000] hpi

Problem Description

Given nn pairwise distinct points (xi,yi)(x_i, y_i) and mm queries. Each query gives A,B,CA, B, C. You need to count the number of pairs (i,j)(i, j) that satisfy xi<xjx_i < x_j, yi<yjy_i < y_j, Axi+Byi+C>0A x_i + B y_i + C > 0, and Axj+Byj+C>0A x_j + B y_j + C > 0.

Input Format

The first line contains two integers n,mn, m.

The next nn lines each contain two integers xi,yix_i, y_i, for i=1,,ni = 1, \dots, n.

The next mm lines each contain three integers, representing a query A,B,CA, B, C.

Output Format

For each query, output one line containing one integer, which is the answer to this query.

5 2
2003 -553
-141 1230
-6854 9658
9319 -1777
7773 3306
1113 -3086 -15864589
162 550 -21287
0
1

Hint

Idea: nzhtl1477 & ccz181078, Solution: ccz181078, Code: ccz181078, Data: ccz181078.

Constraints: For 100%100\% of the testdata, A2+B2>0A^2 + B^2 > 0, A,B,C108|A|, |B|, |C| \le 10^8, 1n,m2×1051 \le n, m \le 2 \times 10^5, xi,yi104|x_i|, |y_i| \le 10^4. The xi,yix_i, y_i are chosen uniformly at random, but it is guaranteed that there are no duplicate points.

For 25%25\% of the testdata, n,m103n, m \le 10^3.

For another 25%25\% of the testdata, A=0A = 0.

For another 25%25\% of the testdata, C=0C = 0.

For another 25%25\% of the testdata, there are no special constraints.

Translated by ChatGPT 5