Pick-up sticks

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.

Hint

Huge input,scanf is recommended.
 

题目大意,先后给出n条直线,求最后哪些直线上没有直线.

那么,由于n最大100000,所有肯定不能用普通的来.

其实,我们只要记录最上面的几条直线就行了,并且可以用动态数组来.毕竟只有100000条直线,却有可能有n个集合,也有可能只有1个,所有,用vector代替普通的数组是再好不过的了.

然而,数据实在太强,还是TLE了.然而...暴力加break优化却AC了!!!

 #include<cmath>
 #include<cstring>
 #include<cstdio>
 #include<algorithm>
 #include<vector>
 #define Vec point
 using namespace std;
 ;
 vector <int> que;
 int n;
 ];
 struct point{
     double x,y;
     void read(){scanf("%lf%lf",&x,&y);}
 }seg[][];
 :x>eps;}
 Vec operator + (point u,Vec v){
     Vec ret; ret.x=u.x+v.x,ret.y=u.y+v.y;
     return ret;
 }
 Vec operator - (point u,point v){
     Vec ret; ret.x=u.x-v.x,ret.y=u.y-v.y;
     return ret;
 }
 Vec operator * (Vec u,double v){
     Vec ret; ret.x=u.x*v,ret.y=u.y*v;
     return ret;
 }
 Vec operator / (Vec u,double v){
     Vec ret; ret.x=u.x/v,ret.y=u.y/v;
     return ret;
 }
 double cross(Vec u,Vec v){return u.x*v.y-u.y*v.x;}
 bool dotonseg(point P,point U,point V){
     ) ;
     ) ;
     ;
 }
 bool intersect(point P,point Q,point U,point V){
     &&fabso(cross(U-P,Q-P)*cross(V-P,Q-P))<) ;
     bool g1=dotonseg(P,U,V);
     bool g2=dotonseg(Q,U,V);
     bool g3=dotonseg(U,P,Q);
     bool g4=dotonseg(V,P,Q);
     ;
     ;
 }
 int main(){
     for (scanf("%d",&n); n; scanf("%d",&n)){
         memset(f,,sizeof f);
         ; i<=n; i++) seg[i][].read(),seg[i][].read();
         ; i<=n-; i++)
             ; j<=n; j++)
             ],seg[i][],seg[j][],seg[j][])){f[i]=; break;}
         printf("Top sticks:");
         ; i<n; i++) if (f[i]) printf(" %d,",i);
         printf(" %d.\n",n);
     }
     ;
 } 

Pick-up sticks的更多相关文章

  1. The 2015 China Collegiate Programming Contest D.Pick The Sticks hdu 5543

    Pick The Sticks Time Limit: 15000/10000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others ...

  2. 2015南阳CCPC D - Pick The Sticks dp

    D - Pick The Sticks Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description The story happened lon ...

  3. CDOJ 1218 Pick The Sticks

    Pick The Sticks Time Limit: 15000/10000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others ...

  4. 2015南阳CCPC D - Pick The Sticks 背包DP.

    D - Pick The Sticks Description The story happened long long ago. One day, Cao Cao made a special or ...

  5. UESTC 1218 Pick The Sticks

    Time Limit: 15000/10000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit  Status ...

  6. hdu 5543 Pick The Sticks(动态规划)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5543 题意:给你一根长为m的长木板和一些小木棒,每一根小木棒有它的长度和价值,这些小木棒要放在长木板上 ...

  7. DP(01背包) UESTC 1218 Pick The Sticks (15CCPC C)

    题目传送门 题意:长度为L的金条,将n根金棍尽可能放上去,要求重心在L上,使得价值最大,最多有两条可以长度折半的放上去. 分析:首先长度可能为奇数,先*2.然后除了两条特殊的金棍就是01背包,所以dp ...

  8. [HDOJ5543]Pick The Sticks(DP,01背包)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5543 题意:往长为L的线段上覆盖线段,要求:要么这些线段都在L的线段上,要么有不超过自身长度一半的部分 ...

  9. uestc oj 1218 Pick The Sticks (01背包变形)

    题目链接:http://acm.uestc.edu.cn/#/problem/show/1218 给出n根木棒的长度和价值,最多可以装在一个长 l 的容器中,相邻木棒之间不允许重叠,且两边上的木棒,可 ...

  10. HDU 5543 Pick The Sticks

    背包变形.与普通的背包问题不同的是:允许有两个物品可以花费减半. 因此加一维即可,dp[i][j][k]表示前i个物品,有j个花费减半了,总花费为k的情况下的最优解. #pragma comment( ...

随机推荐

  1. 如何让浏览器不解析html?

    原问题: 在页面中,除了xmp,textarea以及js转义外,还有什么办法可以让html标签在不被浏览器解析而正常显示呢? 答: 要符合“内部的html标签不被解析”,我们根据HTML5的标准,分元 ...

  2. 【Python】【网络编程】

    #[[网络编程]] # 网络通信就是两个进程之间在通信 # [TCP/IP]'''TCP/IP简介 阅读: 125242虽然大家现在对互联网很熟悉,但是计算机网络的出现比互联网要早很多. 计算机为了联 ...

  3. 基于 Python 和 Pandas 的数据分析(2) --- Pandas 基础

    在这个用 Python 和 Pandas 实现数据分析的教程中, 我们将明确一些 Pandas 基础知识. 加载到 Pandas Dataframe 的数据形式可以很多, 但是通常需要能形成行和列的数 ...

  4. Jenkins--Credentials添加证书从git上拉代码

    直接上图:

  5. python中关于列表和元祖的基础知识

    一,列表 1)定义: []内以逗号分隔,按照索引,存放各种数据类型,每一个位置代表一个元素 2)特性: 1 可存放多个值 2 按照从左到右的顺序定义列表元素,下标为零开始顺序访问,有序 3可修改指定索 ...

  6. django表单的Widgets

    不要将Widget与表单的fields字段混淆.表单字段负责验证输入并直接在模板中使用.而Widget负责渲染网页上HTML表单的输入元素和提取提交的原始数据.widget是字段的一个内在属性,用于定 ...

  7. Qt532界面.ZC测试

    ZC:Delphi中只要随便拖几个控件,设置一下属性就OK了.但是,Qt中 貌似没有 方便的方式来做这个... ZC:目前的解决方案是:Qt中 拖几个控件,然后点 工具条里面的 "栅格布局( ...

  8. scala函数式编程(一)

    scala函数编程特点: 1.Scala函数使用命名参数: 即函数参数传递的实参与函数名相对应,与函数位置不对应. object Test { def main(args: Array[String] ...

  9. 学习笔记5—Python 将多维数据转为一维数组 (总结)

    <code class="language-python">import operator from functools import reduce a = [[1,2 ...

  10. 虚拟机上自动化部署(EFI网络安装)ESXi服务器遇到的问题

    1,虚拟机的CPU为2核或以上. 2,虚拟机选项中不选择: 启用UEFI安全引导.3,引导延迟:设置3000毫秒或以上 4,#GP Exception 13 in world 1:unknown @ ...