Repairing
来源:互联网 发布:patternlayout源码 编辑:程序博客网 时间:2024/05/22 07:04
题目描述:
H. Repairing
Time Limit: 5000ms
Memory Limit: 65536KB
64-bit integer IO format: %lld Java class name: Main
Submit Status PID: 39570
Repairing
In the International City of Pipe Construction, it is planned to repair the water pipe at a certain point in the water pipe network. The network consists of water pipe segments, stop valves and source point. A water pipe is represented by a segment on a 2D-plane and intersected pair of water pipe segments are connected at the intersection point. A stop valve, which prevents from water flowing into the repairing point while repairing, is represented by a point on some water pipe segment. In the network, just one source point exists and water is supplied to the network from this point.
Of course, while repairing, we have to stop water supply in some areas, but, in order to reduce the risk of riots, the length of water pipes stopping water supply must be minimized. What you have to do is to write a program to minimize the length of water pipes needed to stop water supply when the coordinates of end points of water pipe segments, stop valves, source point and repairing point are given.
Input
A data set has the following format:
N M
xs1 ys1 xd1 yd1
…
xsN ysN xdN ydN
xv1 yv1
…
xvM yvM
xb yb
xc yc
The first line of the input contains two integers, N (1 ≤ N ≤ 300) and M (0 ≤ M ≤ 1,000) that indicate the number of water pipe segments and stop valves. The following N lines describe the end points of water pipe segments. The i-th line contains four integers, xsi, ysi, xdi and ydi that indicate the pair of coordinates of end points of i-th water pipe segment. The following M lines describe the points of stop valves. The i-th line contains two integers, xvi and yvi that indicate the coordinate of end points of i-th stop valve. The following line contains two integers, xb and yb that indicate the coordinate of the source point. The last line contains two integers, xc and yc that indicate the coordinate of the repairing point.
You may assume that any absolute values of coordinate integers are less than 1,000 (inclusive.) You may also assume each of the stop valves, the source point and the repairing point is always on one of water pipe segments and that that each pair among the stop valves, the source point and the repairing point are different. And, there is not more than one intersection between each pair of water pipe segments. Finally, the water pipe network is connected, that is, all the water pipes are received water supply initially.
Output
Print the minimal length of water pipes needed to stop water supply in a line. The absolute or relative error should be less than or 10-6. When you cannot stop water supply to the repairing point even though you close all stop valves, print “-1” in a line.
Sample Input 1
1 2
0 0 10 0
1 0
9 0
0 0
5 0
Output for the Sample Input 1
9.0
Sample Input 2
5 3
0 4 2 4
0 2 2 2
0 0 2 0
0 0 0 4
2 0 2 4
0 2
1 0
2 2
1 4
2 1
Output for the Sample Input 2
3.0
Sample Input 3
2 1
0 0 0 4
0 2 2 2
1 2
0 1
0 3
Output for the Sample Input 3
-1
题解:
思路是有但是轩哥还没过….
重点:
代码:
- Repairing
- POJ 3216 Repairing Company
- poj 3216 Repairing Company
- hdoj 3203 Door Repairing
- poj3216 Repairing Company
- POJ3216--Repairing Company
- Repairing a Road
- Repairing a Road
- Repairing a Road NBUT
- Upgrading and Repairing Microsoft Windows
- Effectively Repairing Windows 2003 Server
- POJ3216——Repairing Company
- YTU 2547: Repairing a Road
- toj 4611 Repairing a Road
- Upgrading and Repairing Networks (5th Edition)
- Installing, Troubleshooting, and Repairing Wireless Networks
- poj 3216 Repairing Company 最小路径覆盖
- 问题 Q: 2010省赛题:Repairing a Road
- C#定时器
- 创建标签
- Connect
- backbone.js选型使用分析
- CSDN学院系统停站升级公告
- Repairing
- 镜像地址
- 更新日志 - BugHD iOS 客户端上线
- Android 中TextView内容过长加省略号
- 快速排序
- 宽字符sql注入
- java中try中return语句与finally块执行顺序问题
- LeetCode---Happy Number
- jQuery入门学习笔记----第二章 jQuery选择器