In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
In the middle of the night Bitratio turned on the lamp at the entrance to the building that Byteasar lives in. Now the strong light prevents Byteasar from sleeping. While the lamp does not shine directly on Byteasar's windows, it does so by reflecting in other windows. Deprived of sleep, Byteasar is becoming irritated. To remedy that he tries to occupy his mind, but all he can think of is the light. Thus Byteasar looked out the window and wondered if his neighbours suffer similar torture, i.e., whether the light shines on their windows as well. Now that is an interesting question, at least in Byteasar's opinion. You learn of the puzzle sooner than you would wish: unable to solve the problem all by himself, thinking little of sleep now (be it his and yours), Byteasar calls you to ask for help. You know him well enough to understand that you too will not get any sleep until you write a program that solves his problem.
Byteasar lives in the building , which has windows. The lamp is situated on a wall at the very bottom of this building. Opposite the building , exactly 10 meters apart, there is another building, . The wall of this -windowed building is parallel to the wall of , the Byteasar's building.
The lamp light behaves like you would expect, i.e., in the way predicted by geometrical optics (or ray optics). Namely the light propagates along rays, and if a ray hits a window, it is reflected. Due to The Law of Reflection, the angle of the ray's reflection equals the angle of incidence.
We introduce coordinate systems on the the walls of the two buildings in the following way. Both axes are horizontal, while both axes are vertical; the axes on both walls are identically oriented, and the points of the walls are opposite one another. The windows (on either building) are simply rectangles with sides parallel to the axes of the coordinate system. A ray is reflected only in the interior of any window; it is absorbed on the window's boundary. In each building, no two windows share any part of their interiors. The lamp is located on the wall of the building at the point , which is neither inside nor at the boundary of any window.
In the first line of the standard input there are two integers and (), separated by a single space, denoting the number of windows in the first and second building respectively. The lines that follow describe the windows in Byteasar's building (the building), one per line.
The line no. (for ) holds four integers , , , (, ), separated by single spaces. Such quadruple means that the -th window of the building is a rectangle whose lower-left and upper-right corners' coordinates in meters are and respectively.
The following lines specify the windows of the building is a similar way.
In the first line of the standard output your program should print the number of windows in the building whose interiors are hit by some ray. You may assume that in every test instance there will be at least one such window (the Byteasar's window).
In the second line the numbers of these windows (windows are numbered starting from 1) should be printed in increasing order, separated by single spaces.
For the input data:
3 3 -1 2 1 4 -1 5 1 7 -3 8 -2 20 -1 1 1 2 -1 4 1 5 -1 7 1 10
the correct result is:
2 1 2
Example explanation: A ray hits the first window of the building after being reflected in the first window of the building (for instance, after being reflected at the point of it hits the point of ). To hit the second window of , the ray has to be reflected three times - the very same ray hits the point inside the second window of , and then in the second window of . No ray hits the third window of . Let us mention that every point on the wall of the building is hit by some ray, but in the figure we depicted only those rays that hit some windows of after reflection.
Task author: Jakub Onufry Wojtaszczyk.