#P4073. [WC2013] 平面图

    ID: 3014 远端评测题 5000ms 500MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>图论计算几何2013倍增平衡树WC/CTSC/集训队枚举,暴力生成树

[WC2013] 平面图

Description

In a plane, there are nn vertices and mm line segments. The ii-th vertex has coordinates (xi,yi)(x_i, y_i). The jj-th line segment connects vertex uju_j and vertex vjv_j and has weight hjh_j. Except for its endpoints uju_j and vjv_j, segment jj 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 xx and yy, there always exists a sequence of vertices a1,a2,,aka_1, a_2, \cdots, a_k such that a1=xa_1 = x, ak=ya_k = y, and for every 1i<k1 \le i < k, aia_i and ai+1a_{i+1} are directly connected by a segment.

These mm 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 qq queries. In each query, two arbitrary points AA and BB in the plane are given; neither is a vertex and neither lies on any segment. Draw a curve connecting AA and BB 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 n,mn, m, denoting the number of vertices and the number of line segments.

The next nn lines each contain two integers. In this part, the ii-th line (the (i+1)(i+1)-th line overall) contains two integers xi,yix_i, y_i, the coordinates of vertex ii.

The next mm lines each contain three positive integers u,v,hu, v, h, indicating there is a line segment connecting vertex uu and vertex vv with weight hh. Here uvu \ne v.

The next line contains a single positive integer qq, the number of queries.

The next qq lines each contain four real numbers Ax,Ay,Bx,ByA_x, A_y, B_x, B_y, representing one query whose two points are (Ax,Ay)(A_x, A_y) and (Bx,By)(B_x, B_y).

Output Format

Output qq lines, each containing an integer, which is the answer for each query in order. If AA can reach BB without crossing any segment, output 00. If no valid curve exists, output 1-1.

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:

QQ20180112214336.png

Constraints and notes:

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

For all data, it holds that 5n,m,q1000005 \le n, m, q \le 100000. All segment weights do not exceed 10910^9. All query coordinates are real numbers not exceeding 10710^7, and are guaranteed to be multiples of 0.50.5.

Translated by ChatGPT 5