#P4073. [WC2013] 平面图
[WC2013] 平面图
Description
In a plane, there are vertices and line segments. The -th vertex has coordinates . The -th line segment connects vertex and vertex and has weight . Except for its endpoints and , segment does not pass through any other vertex. If any two segments have a common point, that point must be a vertex, and in that case both segments connect to this vertex. For any two vertices and , there always exists a sequence of vertices such that , , and for every , and are directly connected by a segment.
These segments divide the plane into several regions. Exactly one region is unbounded and the others are bounded. We call the unbounded region the forbidden region.
You are given queries. In each query, two arbitrary points and in the plane are given; neither is a vertex and neither lies on any segment. Draw a curve connecting and that does not pass through the forbidden region or any vertex, and minimize the maximum weight among all segments crossed by the curve. For each query, you need to output this minimal possible value.
Input Format
The first line contains two positive integers , denoting the number of vertices and the number of line segments.
The next lines each contain two integers. In this part, the -th line (the -th line overall) contains two integers , the coordinates of vertex .
The next lines each contain three positive integers , indicating there is a line segment connecting vertex and vertex with weight . Here .
The next line contains a single positive integer , the number of queries.
The next lines each contain four real numbers , representing one query whose two points are and .
Output Format
Output lines, each containing an integer, which is the answer for each query in order. If can reach without crossing any segment, output . If no valid curve exists, output .
9 12
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
1 2 10
2 3 10
3 6 10
6 9 10
9 8 10
8 7 10
7 4 10
4 1 10
2 5 3
5 8 2
5 6 4
4 5 1
3
1.5 1.5 2.5 2.5
1.5 2.5 2.5 1.5
0.5 0.5 1.5 1.5
2
3
-1
Hint
Sample explanation:

Constraints and notes:
This problem has test points. The scale and features of each test point are as follows:

For all data, it holds that . All segment weights do not exceed . All query coordinates are real numbers not exceeding , and are guaranteed to be multiples of .
Translated by ChatGPT 5
京公网安备 11011102002149号