#P4557. [JSOI2018] 战争

[JSOI2018] 战争

Description

Jiu Tiao Keliang is a girl who loves reading.

In a novel she is reading recently, there is a story about two hostile tribes. The first tribe has nn people, and the second tribe has mm people. The position of each person can be abstracted as a point with coordinates (xi,yi)(x_i,y_i) on the 2D plane.

In the novel, people have a strong sense of territory. For any point on the plane, if it is contained (including the boundary) in a triangle formed by three people from the same tribe (which may degenerate into a line segment), then this point belongs to that tribe’s territory. If there exists a point that lies in the territories of both tribes at the same time, then the two tribes will go to war to fight for that point.

Years of war have exhausted both tribes, so the leader of the second tribe made a wise decision. He plans to choose a vector (dx,dy)(dx,dy) and move all his people by this vector, i.e., the coordinates of every person in the second tribe become (xi+dx,yi+dy)(x_i+dx,y_i+dy).

Now he has prepared qq candidate migration plans. For each plan, he wants you to determine whether, after the migration, the two tribes will still go to war over territory.

Input Format

The first line contains three integers n,m,qn,m,q, denoting the numbers of people in the two tribes and the number of candidate migration plans.

The next nn lines each contain two integers xi,yix_i,y_i, denoting the coordinates of the people in the first tribe.

The next mm lines each contain two integers xi,yix_i,y_i, denoting the coordinates of the people in the second tribe.

The next qq lines each contain two integers dxi,dyidx_i,dy_i, denoting a migration plan.

The input guarantees that all people’s coordinates are pairwise distinct.

Output Format

For each migration plan, output one integer per line. Output 00 if no conflict will happen, and 11 if a conflict will happen.

4 4 3
0 0
1 0
0 1
1 1
-1 0
0 3
0 2
0 -1
0 0
2 3
0 -1
1
0
1

Hint

Sample 1 Explanation

The figure below shows the territories of the two tribes in the first plan. The point (0,0)(0,0) belongs to both tribes, so a war will happen.

0

The figure below shows the territories of the two tribes in the second plan. No point belongs to both tribes, so no war will happen.

1

The figure below shows the territories of the two tribes in the third plan. The point (0,0)(0,0) belongs to both tribes, so a war will happen.

2

Constraints

For 20%20\% of the testdata, n,m5,q500n,m\le 5,q\le 500.

For 40%40\% of the testdata, n,m50,q500n,m\le 50,q\le 500.

For 70%70\% of the testdata, n,m104,q500n,m\le 10^4,q\le 500.

For 100%100\% of the testdata, n,m105,q105n,m\le 10^5,q\le 10^5.

For 100%100\% of the testdata, it is guaranteed that 108xi,yi,dxi,dyi108-10^8\le x_i,y_i,dx_i,dy_i\le 10^8 and n,m3n,m\ge 3. All people’s coordinates are pairwise distinct, and for each tribe, not all people are collinear.

2024/08/20 Added 6 sets of hack testdata, and made them public in the attachments of this problem.

Translated by ChatGPT 5