luogu#P5045. [SCOI2003] 蜘蛛难题
[SCOI2003] 蜘蛛难题
Problem Description
There is a set of pipes and a spider , as shown in the figure below. All pipes are open at the top and sealed at the bottom. Each pipe has a diameter of . The connections between two pipes have infinite capacity, but their volume can be ignored.

Above the first pipe there is a water source, from which water keeps flowing downward at a rate of per second. Since the cross-sectional area of a pipe is , when filling only one pipe, the water level rises by per second. According to physics, during the first seconds, the water flows into the bottom of the left pipe; during seconds , it flows into the right pipe; during seconds , it flows into both pipes at the same time (although the total flow rate is unchanged, because two pipes are filled simultaneously, the rising speed in each pipe is only per second), and then it reaches the spider.
Given the positions of the connections between pipes and the position of the spider , find the time when the water level touches . Assume the spider’s actual position is slightly higher than the given one. Therefore, if the spider is at position in the left pipe, the answer should be seconds. This is because after the first two seconds the water level seems to touch , but it is actually slightly below .
Input Format
All positions are represented by ordered pairs , where the coordinate increases from top to bottom, and the coordinate increases from left to right. Therefore, the top-left corner is . All other coordinate values are integers between and .
The first line contains an integer , the number of pipes. The next lines each contain three integers describing one pipe. is the coordinate of the top-left corner of the pipe, and is the height of the pipe .
The next line contains an integer , the number of connections.
The next lines each contain three integers describing a connection. is the coordinate of the left endpoint, and is the length of the connection .
The last line contains two integers , meaning that is in pipe at the position whose coordinate is . Pipes are numbered in the order they appear in the input file.
The following assumptions hold: the water source is always directly above the first pipe; connections do not cross pipes; the coordinates of any two connections are different; the coordinates of the top-left corners of any two pipes are different; and both endpoints of every connection lie on pipes (there will be no “hanging” endpoints).
Output Format
Output only one integer: the time when the water level touches . If the water level can never touch , output .
2
2 0 6
5 1 6
1
3 4 2
2 2
9
Hint
Translated by ChatGPT 5