spoj#INS14K. Digo Goes Training
Digo Goes Training
Digo is being trained for shooting as it is a very integral part of his missions. His trainer sets up a training arena for him to practice for it. Digo is taken to the ground where many strong penetrable walls are placed in arbitrary manner. Consider the ground to be a rectangular grid with cartesian coordinates. Digo fires the bullets from a given point on the X-axis. The bullets can only travel parallel to the Y-axis. Given the endpoints of the walls and Digo's current position on the X-axis, he wants to know how many walls he will penetrate with each shot. The shots will only penetrate the wall, they are not powerful enough to break them. As he is very weak in mathematics, he asks you to help him.
Input :
The first line consists of the number of test cases, T.
The second line contains the number of walls N.
Then N lines follow. Each line contains 4 integers denoting the endpoints of the walls i.e. x1 y1 x2 y2.
Next line denotes Q, the number of queries.
Queries can be of two types:
1 x1 y1 x2 y2 : which denotes the endpoints of new wall placed.
0 pos : where pos tells about the x coordinate of Digo’s position. The position will be a floating point number.having exactly two digits after the decimal.
Output Format:
Output one line for each query of form 0. For each query of the form ‘0 pos’ output the numbers of walls penetrated.
Input Constraints:
1 <= T <= 10
1 <= N <= 1000
1 <= Q <= 1000
0 <= x1, y1, x2, y2 <= 20000
0.00 <= pos <= 20000.00
Sample Input:
1
3
3 5 7 8
1 3 5 6
2 4 8 9
4
0 6.73
1 4 7 9 8
1 2 5 6 3
0 3.55
Sample Output:
2
4
Input :
The first line consists of the number of test cases, T.
The second line contains the number of walls N.
Then N lines follow. Each line contains 4 integers denoting the endpoints of the walls i.e. x1 y1 x2 y2.
Next line denotes Q, the number of queries.
Queries can be of two types:
1 x1 y1 x2 y2 : which denotes the endpoints of new wall placed.
0 pos : where pos tells about the x coordinate of Digo’s position. The position will be a floating point number.having exactly two digits after the decimal.
Output Format:
Output one line for each query of form 0. For each query of the form ‘0 pos’ output the numbers of walls penetrated.
Input Constraints:
1 <= T <= 10
1 <= N <= 1000
1 <= Q <= 1000
0 <= x1, y1, x2, y2 <= 20000
0.00 <= pos <= 20000.00
Sample Input:
1
3
3 5 7 8
1 3 5 6
2 4 8 9
4
0 6.73
1 4 7 9 8
1 2 5 6 3
0 3.55
Sample Output:
2
4