The Doors
The Doors
Input
2
4 2 7 8 9
7 3 4.5 6 7
The first line contains the number of interior walls. Then there is a line for each such wall, containing five real numbers. The first number is the x coordinate of the wall (0 < x < 10), and the remaining four are the y coordinates of the ends of the doorways in that wall. The x coordinates of the walls are in increasing order, and within each line the y coordinates are in increasing order. The input file will contain at least one such set of data. The end of the data comes when the number of walls is -1.
Output
Sample Input
1 5 4 6 7 8 2 4 2 7 8 9 7 3 4.5 6 7 -1
Sample Output
10.00 10.06
题目就是说,给你一个10*10的正方形房间,里面会用一些垂直与x轴的墙隔开.每个墙上有两个门,然后给你门的两个端点坐标,要求求出从(0,5)走到(10,5)的最短路;
那其实本质上就是最短路,如果没有墙隔开,就单单这几个点,那就很水了.现在还要求判断一下,某两点之间是否可以直达.所谓直达,就是,这两点的连线不与其他任何墙相交(交于端点是允许的).
至此,题目解完了.
#include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<cmath> #define INF 10000000 using namespace std; ; int n; ][]; ]; ],o; double dis(point a,point b){return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));} :x>eps;} double cross(point a,point b){return a.x*b.y-a.y*b.x;} point operator - (point a,point b){point ret; ret.x=a.x-b.x,ret.y=a.y-b.y; return ret;} int Intersect(point a,point b,point c,point d){ double s1,s2,s3,s4; int d1,d2,d3,d4; d1=dcmp(s1=cross(a-c,b-c)); d2=dcmp(s2=cross(a-d,b-d)); d3=dcmp(s3=cross(c-a,d-a)); d4=dcmp(s4=cross(c-b,d-b)); &&(d3^d4)==-) ; ; } int main(){ ; scanf("%d",&n)){ ,cnt0=; P[].x=,P[].y=; ; i<n; i++){ double x,y1,y2,y3,y4; scanf("%lf%lf%lf%lf%lf",&x,&y1,&y2,&y3,&y4); P[cnt].x=x,P[cnt++].y=y1; P[cnt].x=x,P[cnt++].y=y2; P[cnt].x=x,P[cnt++].y=y3; P[cnt].x=x,P[cnt++].y=y4; seg[cnt0].a.x=x,seg[cnt0].a.y=,seg[cnt0].b.x=x,seg[cnt0++].b.y=y1; seg[cnt0].a.x=x,seg[cnt0].a.y=y2,seg[cnt0].b.x=x,seg[cnt0++].b.y=y3; seg[cnt0].a.x=x,seg[cnt0].a.y=y4,seg[cnt0].b.x=x;seg[cnt0++].b.y=; } P[cnt].x=,P[cnt].y=; ; i<=cnt; i++){ ; j<=cnt; j++) cost[i][j]=INF; cost[i][i]=; } ; i<=cnt; i++){ ; j<=cnt; j++) if (j!=i){ o.a.x=P[i].x,o.a.y=P[i].y,o.b.x=P[j].x,o.b.y=P[j].y; ; ; k<cnt0; k++) ){flag=; break;} ) cost[i][j]=dis(P[i],P[j]); } } ; k<=cnt; k++) ; i<=cnt; i++) ; j<=cnt; j++) if (cost[i][k]+cost[k][j]<cost[i][j]) cost[i][j]=cost[i][k]+cost[k][j]; printf(][cnt]); } ; }
The Doors的更多相关文章
- poj 1556 The Doors
The Doors Time Limit: 1000 MS Memory Limit: 10000 KB 64-bit integer IO format: %I64d , %I64u Java ...
- POJ 1556 The Doors(线段交+最短路)
The Doors Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5210 Accepted: 2124 Descrip ...
- 100 doors
Question There are 100 doors in a row that are all initially closed. You make 100 passes by the door ...
- poj 1556 The Doors(线段相交,最短路)
The Doors Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 7430 Accepted: 2915 Descr ...
- POJ 1556 The Doors 线段判交+Dijkstra
The Doors Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6734 Accepted: 2670 Descrip ...
- POJ 1556 - The Doors 线段相交不含端点
POJ 1556 - The Doors题意: 在 10x10 的空间里有很多垂直的墙,不能穿墙,问你从(0,5) 到 (10,5)的最短距离是多少. 分析: 要么直达,要么 ...
- POJThe Doors AND NYIST 有趣的问题
POJThe Doors AND NYIST 有趣的问题 题目链接:pid=227" target="_blank">Click Here~ 题目分析: 给你横纵坐 ...
- 【DOORS】如何基于DOORS实施需求管理
引言 IBM Rational DOORS,简称DOORS,是被业界广泛认可的需求管理工具,在国内外需求管理领域具有较高的市场占有率.需求管理作为传统的工程领域,理论发展相对成熟和健全.随着越来越多的 ...
- POJ1556 The Doors [线段相交 DP]
The Doors Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 8334 Accepted: 3218 Descrip ...
- CodeForces 1143A The Doors
The Doors 签到题 #include <iostream> using namespace std; int a[200005]; int main() { int n; scan ...
随机推荐
- AngularJS 笔记1
2017-03-23 本文更新链接: http://www.cnblogs.com/daysme/p/6606805.html 什么是 angularjs 2009年有两个外国人创建,后由谷歌收购并开 ...
- 【译】第24节---Fluent API - 属性映射
原文:http://www.entityframeworktutorial.net/code-first/configure-property-mappings-using-fluent-api.as ...
- ArrayList.clear、=null、new Arraylist之间的对比区别
参考博文 1.使用ArrayList的对象方法clear() List list = new ArrayList(); List list1 = list; list.add(1); list.add ...
- 关于Tortoise git汉化包装了,不管用,仍然是英文菜单的问题记录
今天在装小乌龟(TortoiseGIT)碰到了安装中文语言包不管用的情况,后来在几番折腾之后总算搞定了,但是具体哪一步搞定的,目前原因还不清楚,所以把搞定的过程记录下,留作后用: 1.Tortoise ...
- tomcat+nginx实现均衡负载
在项目运营时,我们都会遇到一个问题,项目需要更新时,我们可能需先暂时关闭下服务器来更新.但这可能会出现一些状况: 1.用户还在操作,被强迫终止了(我们可以看日志等没人操作的时候更新,但总可能会有万一) ...
- 给大一新生学习c程序的一些建议的一些建议
这是一篇给刚学习c程序的学弟们的一篇日志.如果想学好c程序,以及不想走太多弯路,希望能看一下这篇文章,如果说基础较好,或者说已经是大二,大三,这篇文章不会有什么帮助. 刚转到软件工程系,加了几个新生群 ...
- 力扣(LeetCode) 905. 按奇偶排序数组
给定一个非负整数数组 A,返回一个由 A 的所有偶数元素组成的数组,后面跟 A 的所有奇数元素. 你可以返回满足此条件的任何数组作为答案. 示例: 输入:[3,1,2,4] 输出:[2,4,3,1] ...
- 学习笔记15—Python 存储集
1. save using pickle with open('F:/BrainAging/result/ordered_data_final_just_TD_leaveOne.pickle ...
- Lua和C++交互 学习记录之二:栈操作
主要内容转载自:子龙山人博客(强烈建议去子龙山人博客完全学习一遍) 部分内容查阅自:<Lua 5.3 参考手册>中文版 译者 云风 制作 Kavcc vs2013+lua-5.3.3 1 ...
- Java创建WebService
从java 6之后就提供了简单快速的创建WebService的方法,这里将这种简单的方法记录下来方便以后回看.第一步:首先创建一个java Project,然后创建一个类HelloWorldImpl如 ...