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. Java 数据库篇

    一.简易封装JDBC工具类: package com.jackie.MyBatis.main; import java.sql.Connection; import java.sql.DriverMa ...

  2. Java 虚拟机 最易理解的 全面解析

    先上一个最容易理解的类实例化的内存模型案例截图: 转载自:https://www.zybuluo.com/Yano/note/321063 周志明著的<深入理解 Java 虚拟机>的干货~ ...

  3. Java的CountDownLatch和CyclicBarrier的理解和区别

    CountDownLatch和CyclicBarrier的功能看起来很相似,不易区分,有一种谜之的神秘.本文将通过通俗的例子并结合代码讲解两者的使用方法和区别. CountDownLatch和Cycl ...

  4. hybrid cordova+vue开发APP(一) 环境搭建

    没有选择react-navite,而选择cordova+vue2.x,是因为react-navite有学习成本,并且cordova+vue2.x程序员 可以直接上手,性能上可以满足需求,成本低,开发速 ...

  5. 学习笔记46—如何使Word和EndNote关联

    1)打开Word文件项目中的选项,然后点击加载项, 2)找到Endnote安装目录,选择目录中的Configure EndNote.exe,选中configuration endnote compon ...

  6. java 里面耦合和解耦

    百度解释: 耦合是指两个或两个以上的体系或两种运动形式间通过相互作用而彼此影响以至联合起来的现象. 解耦就是用数学方法将两种运动分离开来处理问题. 这是形象搞笑的比喻:完全可以这么想像嘛,有一对热恋中 ...

  7. 第 6 章 存储 - 043 - data-packed volume container

    data-packed volume container 将数据打包到镜像中,然后通过 docker managed volume 共享 1.先用Dockerfile 构建镜像 ADD 将静态文件添加 ...

  8. (转)C# Delegate.Invoke、Delegate.BeginInvoke

    Delegate的Invoke.BeginInvoke 1.Delegate.Invoke (委托同步调用) a.委托的Invoke方法,在当前线程中执行委托. b.委托执行时阻塞当前线程,知道委托执 ...

  9. ThinkPHP表单自动验证(注册功能)

    控制器中: 模型中: 视图中:

  10. linux服务器规格查看

    性能测试前,需要确定服务器规格. 下面汇总下如何查看linux的CPU等规格 1. 查看服务器CPU个数 1)查看物理CPU个数: cat /proc/cpuinfo |grep "phys ...