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

  1. 5
  2. 1 1 4 2
  3. 2 3 3 1
  4. 1 -2.0 8 4
  5. 1 4 8 2
  6. 3 3 6 -2.0
  7. 3
  8. 0 0 1 1
  9. 1 0 2 1
  10. 2 0 3 1
  11. 0

Sample Output

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

Hint

Huge input,scanf is recommended.
 

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

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

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

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

  1. #include<cmath>
  2. #include<cstring>
  3. #include<cstdio>
  4. #include<algorithm>
  5. #include<vector>
  6. #define Vec point
  7. using namespace std;
  8. ;
  9. vector <int> que;
  10. int n;
  11. ];
  12. struct point{
  13. double x,y;
  14. void read(){scanf("%lf%lf",&x,&y);}
  15. }seg[][];
  16. :x>eps;}
  17. Vec operator + (point u,Vec v){
  18. Vec ret; ret.x=u.x+v.x,ret.y=u.y+v.y;
  19. return ret;
  20. }
  21. Vec operator - (point u,point v){
  22. Vec ret; ret.x=u.x-v.x,ret.y=u.y-v.y;
  23. return ret;
  24. }
  25. Vec operator * (Vec u,double v){
  26. Vec ret; ret.x=u.x*v,ret.y=u.y*v;
  27. return ret;
  28. }
  29. Vec operator / (Vec u,double v){
  30. Vec ret; ret.x=u.x/v,ret.y=u.y/v;
  31. return ret;
  32. }
  33. double cross(Vec u,Vec v){return u.x*v.y-u.y*v.x;}
  34. bool dotonseg(point P,point U,point V){
  35. ) ;
  36. ) ;
  37. ;
  38. }
  39. bool intersect(point P,point Q,point U,point V){
  40. &&fabso(cross(U-P,Q-P)*cross(V-P,Q-P))<) ;
  41. bool g1=dotonseg(P,U,V);
  42. bool g2=dotonseg(Q,U,V);
  43. bool g3=dotonseg(U,P,Q);
  44. bool g4=dotonseg(V,P,Q);
  45. ;
  46. ;
  47. }
  48. int main(){
  49. for (scanf("%d",&n); n; scanf("%d",&n)){
  50. memset(f,,sizeof f);
  51. ; i<=n; i++) seg[i][].read(),seg[i][].read();
  52. ; i<=n-; i++)
  53. ; j<=n; j++)
  54. ],seg[i][],seg[j][],seg[j][])){f[i]=; break;}
  55. printf("Top sticks:");
  56. ; i<n; i++) if (f[i]) printf(" %d,",i);
  57. printf(" %d.\n",n);
  58. }
  59. ;
  60. }

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. Quartus工程中各文件类型的含义

    https://blog.csdn.net/jingliangliu/article/details/52245497 .jic           JTAG Indirect Configurati ...

  2. .Net ASP.NET 打开指定文件夹

    比如要打开指定的文件夹,而不是弹出对话框 System.Diagnostics.Process.Start(@"D:\"); 这样就打开了D盘,和正常打开D盘是一样的.

  3. git 恢复单个文件的历史版本

    首先查看该文件的历史版本信息:git log Default@2x.png 记录下需要恢复的commit版本号:如 9aa51d89799716aa68cff3f30c26f8815408e926 恢 ...

  4. 【BZOJ】4011: [HNOI2015]落忆枫音

    题目链接:http://blog.csdn.net/popoqqq/article/details/45194103 写代码的时候也没有很清晰....具体看这里吧 #include<iostre ...

  5. Spring Boot的数据访问 之Spring Boot + jpa的demo

    1. 快速地创建一个项目,pom中选择如下 <?xml version="1.0" encoding="UTF-8"?> <project x ...

  6. SSL证书申请,如何快速通过SSL文件验证。

    申请SSL证书会让我们进行验证域名,一般方式如下: 1.FTP验证 2.文件验证 3.DNS验证 这三种方式各有各的优缺点,本文解决如何在IIS的环境下通过sslforfree网站的文件验证. 域名: ...

  7. winfrom 动态添加控件,以及删除

      private void btnadd_Click(object sender, EventArgs e)         {             int fileCount = 0;     ...

  8. 大数据时代的Python金融应用-Day1-Python与金融应用概述

    一.Python语言的主要特征 1.开源性 Python和大多数的支撑库和工具都是开源的,通常可以非常灵活的使用而且有开放的协议. 2.解释性 也可以使用Cpython完成将解释性语言转化为实施可执行 ...

  9. PHP中如何命令行

    PHP中如何命令行 一.总结 一句话总结:配置php系统环境,然后命令行中运行 php -f 文件名即可 配置php系统环境 php_-f_文件名 例如: 1.三种运行php的方式? 运行文件_-f ...

  10. spring cloud: Hystrix(七):Hystrix的断容器监控dashboard

    Hystrix的断容器监控dashboard. dashboard是用来监控Hystrix的断容器监控的,图形化dashboard是如何实现指标的收集展示的. dashboard 本地端口8730 项 ...