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);
     }
     ;
 } 

最新文章

  1. 在linux上安装psycopg2出错--Error: pg_config executable not found.
  2. 有联系的jQuery选择器
  3. webView中支持input的file的选择和alert弹出
  4. Python新手学习基础之函数-可变参数**
  5. Android 纯代码加入点击效果
  6. DevExpress XtraReports 入门二 创建 data-aware(数据感知) 报表
  7. 使用JS实现手风琴效果
  8. Servlet 3.0/3.1 中的异步处理
  9. Spring MVC 处理异常的3种方式
  10. App 组件化/模块化之路——Android 框架组件(Android Architecture Components)使用指南
  11. 带你走进SAP项目实施过程——立项(1)
  12. CSS后代选择器“空格”和“&gt;”的使用辨析
  13. ActivityJump+ActivityManager【Activity之间的跳转和Activity任务栈管理】
  14. Javascript_06_表单验证(离开单项,输入框后提示信息)
  15. lasticsearch最佳实践之分片使用优化
  16. mysql 单表更新记录UPDATE
  17. Andrew NG 机器学习编程作业4 Octave
  18. 使用Wscript/cscript调用VB脚本
  19. react router @4 和 vue路由 详解(七)react路由守卫
  20. Linux环境下查看线程数的几种方法

热门文章

  1. Hexo搭建(VPS)
  2. _spellmod_leech_spell
  3. 小程序scss页面布局
  4. Tp5.1使用导出Excel
  5. Web阶段总结以及感受(附带大一结束暑期学习的纲要)
  6. [osg]osg背景图设置
  7. 一个请求需要调用两个不同的数据库 添加DbContext
  8. 学习笔记56—Endnote参考文献格式调整
  9. EasyUI datebox 设置不可编辑后再次修改为可编辑失效的解决
  10. Codeforces 801B - Valued Keys