计算几何-hdoj-1147-Pick-up sticks

简介: Pick-up sticks 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 stic

Pick-up sticks


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.

微笑大意:按顺序往地上扔木棍,给出每根木棍的两个端点坐标。问最后有哪些木棍没有被其他木棍压倒。要求按次序输出。

分析:两个for循环,判断当前木棍有没有被后面的压到。压到等价于两线段相交。线段端点相交这种情况不用考虑。





目录
相关文章
|
Java Linux 网络安全
2021 最新 IntelliJ IDEA配置 远程Docker容器 编写Dockerfile文件 步骤演示(图文版)
目录 一. 配置远程SFTP 1.打开IDEA 2.建个springboot项目 2.1 选择tools 2.2 选择如图所示位置 2.4 出现如下界面,点击三个... 2.5 选择SFTP 2.6 作如下配置,然后点击OK 2.7弹出如下界面,点击见图所示的三个... 2.8 点击加号+ 2.9 配置远程连接信息 2.10测试连接:弹出的界面点击 : 是 2.11 根据需求选择,我这里选择root目录 2.12连接完成 3 右键可以新建文件和目录 3.1 点击小箭头提交数据 二. IDEA配置 Linux 命令行窗口 第一步,点击 tools 第二步; 选择这个ssh 第三步: 连接完成
1098 0
2021 最新 IntelliJ IDEA配置 远程Docker容器 编写Dockerfile文件 步骤演示(图文版)
|
JavaScript 开发工具 git
已安装nodejs但是安装hexo报错
已安装nodejs但是安装hexo报错
222 2
|
算法 Java API
java BigDecimal使用详细介绍
java BigDecimal使用详细介绍
327 0
java BigDecimal使用详细介绍
|
机器学习/深度学习 算法 搜索推荐
多任务学习模型之DBMTL介绍与实现
本文介绍的是阿里在2019年发表的多任务学习算法。该模型显示地建模目标间的贝叶斯网络因果关系,整合建模了特征和多个目标之间的复杂因果关系网络,省去了一般MTL模型中较强的独立假设。由于不对目标分布做任何特定假设,使得它能够比较自然地推广到任意形式的目标上。
|
负载均衡 算法 应用服务中间件
解密Nginx负载均衡:实现流量分发与故障转移
解密Nginx负载均衡:实现流量分发与故障转移
816 1
|
Linux Shell C语言
【Linux系统化学习】进程的父子关系 | fork 进程
上篇文章我们谈到了进程,运行在内存的程序、被执行的指令都可以是一个进程;并且对Linux的进程有一定的认识,知道如何使用指令查看进程和第一个系统调用。进程还有很多的奥秘需要我们探索,让我们开始今天的学习吧!
|
SQL C++ Python
SQL高级查询技巧(两次JOIN同一个表,自包含JOIN,不等JOIN)
掌握了这些,就比较高级啦 Using the Same Table Twice 如下面查询中的branch字段 SELECT a.account_id, e.emp_id, b_a.name open_branch, b_e.
5058 0
|
弹性计算 关系型数据库 MySQL
最全阿里云双11优惠活动攻略价格表,看这一篇就够!
最全阿里云双11优惠活动攻略价格表,看这一篇就够!2023阿里云双11优惠活动开启了,轻量2核2G3M带宽服务器87元一年、2核4G4M带宽165元一年,云服务器ECS经济型e实例2核2G3M固定带宽优惠价格99元一年,新老用户同享,并且续费不涨价,第二年99元续费
1815 2
|
存储 SQL 开发框架
数据库原理与应用(SQL Server)笔记 第九章 存储过程和触发器(上)
数据库原理与应用(SQL Server)笔记 第九章 存储过程和触发器
数据库原理与应用(SQL Server)笔记 第九章 存储过程和触发器(上)
Lodash学习之集合指定递归深度扁平化
Lodash学习之集合指定递归深度扁平化
855 0
Lodash学习之集合指定递归深度扁平化