博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 1147:Pick-up sticks(基本题,判断两线段相交)
阅读量:6493 次
发布时间:2019-06-24

本文共 2273 字,大约阅读时间需要 7 分钟。

Pick-up sticks

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 1872    Accepted Submission(s): 706

Problem Description
Stan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan tries to find the top sticks, that is these sticks such that there is no stick on top of them. Stan has noticed that the last thrown stick is always on top but he wants to know all the sticks that are on top. Stan sticks are very, very thin such that their thickness can be neglected.
 

 

Input
Input consists of a number of cases. The data for each case start with 1 ≤ n ≤ 100000, the number of sticks for this case. The following n lines contain four numbers each, these numbers are the planar coordinates of the endpoints of one stick. The sticks are listed in the order in which Stan has thrown them. You may assume that there are no more than 1000 top sticks. The input is ended by the case with n=0. This case should not be processed. 
 

 

Output
For each input case, print one line of output listing the top sticks in the format given in the sample. The top sticks should be listed in order in which they were thrown. 
The picture to the right below illustrates the first case from input.
 

 

Sample Input
5 1 1 4 2 2 3 3 1 1 -2.0 8 4 1 4 8 2 3 3 6 -2.0 3 0 0 1 1 1 0 2 1 2 0 3 1 0
 

 

Sample Output
Top sticks: 2, 4, 5. Top sticks: 1, 2, 3.
 

 

Source
 

 

Recommend
Eddy   |   We have carefully selected several similar problems for you:            

 
  计算几何,判断两线段相交
  题意是依次放置线段,相交即摞在上面,求最后在最上面的线段。
  急躁了,思路彻底乱了,最后还是参考了别人的代码。比赛的时候如果是这种状态,那绝对会拖累队友。
1 #include 
2 #include
3 #include
4 using namespace std; 5 6 struct Point{ 7 double x,y; 8 }; 9 struct Line{10 Point p1,p2;11 }l[100010];12 double Max(double a,double b)13 {14 return a>b?a:b;15 }16 int MaxInt(int a,int b)17 {18 return a>b?a:b;19 }20 double Min(double a,double b)21 {22 return a
>n){45 if(n==0) break;46 memset(isv,0,sizeof(isv));47 for(int i=1;i<=n;i++){48 scanf("%lf%lf%lf%lf",&l[i].p1.x,&l[i].p1.y,&l[i].p2.x,&l[i].p2.y);49 }50 int num = n;51 for(int i=1;i

 

Freecode :

转载地址:http://ztkyo.baihongyu.com/

你可能感兴趣的文章
我的友情链接
查看>>
Oracle11g Data Guard物理备用数据库搭建与配置(第1部分 主数据库实例创建)
查看>>
即时通讯框架T-io之WebSocket协议再之HelloWorld
查看>>
设计模式读书笔记-观察者模式
查看>>
浅谈java
查看>>
数据库相关概念
查看>>
gogs结合git-webhook自动部署
查看>>
Table中td的长字符串换行处理
查看>>
Objective-C中的isa、class、SEL、IMP
查看>>
head命令
查看>>
对高可用性的exchange2010的 Array配置
查看>>
操作系统中常用的进程调度算法
查看>>
puppet 使用
查看>>
一次网站负载排查记录
查看>>
Mina使用IoHandler实现业务处理
查看>>
The Competition
查看>>
LVM
查看>>
varnish 性能调优
查看>>
高可用网站的软件质量保证
查看>>
Libpcap tutorial-02
查看>>