题目描述
Problem Description
Given $N$ triangles and $M$ lines, where the lines are either parallel to the $x$-axis or the $y$-axis, determine how many triangles each of these $M$ lines intersects.
(A line intersects a triangle if and only if it can divide the triangle into two polygons with non-zero areas.)
Input Format
The first line of input contains a positive integer $N$, representing the number of triangles.
The next $N$ lines each contain three coordinates $(x_1, y_1)$, $(x_2, y_2)$, and $(x_3, y_3)$, describing the vertices of a triangle. These points are not collinear, and all coordinates are non-negative integers. The triangles may overlap.
The next line contains a positive integer $M$, representing the number of lines.
The next $M$ lines each contain a string x = c or y = c (note the spaces around the equals sign), describing a line. Here, c is a non-negative integer.
Output Format
For each line, output a single integer representing the number of triangles it intersects.
Sample Input and Output
Sample Input #1
3
1 0 0 2 2 2
1 3 3 5 4 0
5 4 4 5 4 4
4
x = 4
x = 1
y = 3
y = 1
Sample Output #1
0
1
1
2
Sample Input #2
4
2 7 6 0 0 5
7 1 7 10 11 11
5 10 2 9 6 8
1 9 10 10 4 1
4
y = 6
x = 2
x = 4
x = 9
Sample Output #2
3
2
3
2
Notes
[Data Range]
For $40\%$ of the data, $M \le 300$;
For another $40\%$ of the data, all triangle coordinates are $< 1000$;
For $100\%$ of the data, $2 \le N, M \le 10^5$, and $0 \le x_1, y_1, x_2, y_2, x_3, y_3 < 10^6$.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分