#P7067. [NWRRC 2014] Hiking in the Hills

[NWRRC 2014] Hiking in the Hills

题目描述

Helen is hiking with her friends in a highland. Their plan is to hike from their camp AA to a beautiful showplace BB .

Unfortunately, Helen started feeling dizzy due to altitude sickness. Help her group find a route such that the topmost height on that route is as small as possible.

输入格式

The input file contains full information about the landscape of a square region 106×10610^{6} \times 10^{6} in the following format. The first line contains integer nn — the number of triangles in the landscape (2n2000)(2 \le n \le 2000) . Each of following nn lines contains nine integers $x_{i_1}, y_{i_1}, z_{i_1}, x_{i_2}, y_{i_2}, z_{i_2}, x_{i3}, y_{i3}, z_{i3}$ — coordinates of a triangle. All coordinates belong to the closed interval [0,106][0 , 10^{6}]. The two last lines contain three integers each: xA,yA,zAx_{A}, y_{A}, z_{A} and xB,yB,zBx_{B}, y_{B}, z_{B} — coordinates of the camp A and the showplace BB .

The given triangles are guaranteed to describe a consistent continuous landscape. Projections of triangles onto XYXY plane are non-degenerate and fill the square without overlapping. A vertex of one triangle never lays inside an edge of another triangle. Points AA and BB belong to the landscape surface and are different.

输出格式

Output a polyline route from AA to BB with the smallest possible topmost height. The first line should contain mm , the number of vertices in this polyline. Each of following mm lines should contain three integer coordinates of a polyline vertex: xi,yi,x_{i}, y_{i}, and zi.z_{i}. Vertices must be listed along the polyline, from AA to BB (including these two endpoints).

All coordinates of polyline vertices should be integer. Each polyline edge must belong to some triangle from the input file (possibly, to its edge). The number of vertices in the polyline must not exceed 5n5n.

8
1000000 0 0 1000000 1000000 150000 600000 600000 400000
0 1000000 0 600000 600000 400000 600000 1000000 300000
0 1000000 0 400000 300000 150000 600000 600000 400000
400000 0 200000 1000000 0 0 400000 300000 150000
400000 300000 150000 1000000 0 0 600000 600000 400000
600000 600000 400000 1000000 1000000 150000 600000 1000000 300000
0 0 0 400000 0 200000 400000 300000 150000
0 1000000 0 0 0 0 400000 300000 150000
100000 700000 37500
900000 400000 137500

4
100000 700000 37500
400000 300000 150000
900000 150000 100000
900000 400000 137500

提示

Time limit: 2 s, Memory limit: 256 MB.