#P4261. Cloud Overlap
Cloud Overlap
Cloud Overlap
In the -coordinate plane, there are clouds, each represented by a 5-tuple . Here, is the coordinate of the lower-left vertex of the cloud, is the width (extension along the -axis), is the height (extension along the -axis) of the cloud, and indicates its moving direction. If , the cloud moves horizontally in the positive -direction at a speed of unit per second; if , it moves vertically in the positive -direction at the same speed.
At time , it is guaranteed that no two clouds have overlapping interior areas (their interiors are disjoint). A point at time is covered by a cloud if and only if it lies in the interior (boundaries excluded) of the cloud’s rectangle at that time. For a horizontal cloud (i.e. ), its rectangle at time is given by the open interval ( (x_i+t,,x_i+t+w_i) ) in the -axis and ( (y_i,,y_i+h_i) ) in the -axis. For a vertical cloud (i.e. ), its rectangle at time becomes ( (x_i,,x_i+w_i) ) in the -axis and ( (y_i+t,,y_i+t+h_i) ) in the -axis.
Your task is to determine the maximum number of clouds that can cover the same point at the same time (for any real time and any point in the plane). Note that since the interiors of two clouds of the same moving group (both horizontal or both vertical) do not overlap (because they are non overlapping at time and their relative positions remain fixed in the non-translating coordinate), the only possibility for a point to be covered by more than one cloud is when the point lies in the intersection of a horizontal and a vertical cloud. Therefore, the answer is:
- , when there are no clouds;
- , when all clouds move in the same direction;
- , when there is at least one horizontal and at least one vertical cloud.
Write a program to help determine the answer.
inputFormat
The first line contains an integer (), representing the number of clouds. Each of the following lines contains five numbers: , , , , and (with ). These values describe the cloud's lower-left corner, its width, its height, and its moving direction respectively.
outputFormat
Output a single integer representing the maximum number of clouds covering the same point at any moment.
sample
1
0 0 3 4 0
1
</p>